nus-yam/ex-repair huggingface dataset:
Program: 84758
Project: 84758
Buggy source:
private void populateDosage(List<Object> row,DrugDosageContract dosage){
  String drugName=StringUtils.EMPTY;
  String dosageTypeId=StringUtils.EMPTY;
  String morningTime=StringUtils.EMPTY;
  String eveningTime=StringUtils.EMPTY;
  Integer offsetDays=null;
  String startDate=null;
  String advice=StringUtils.EMPTY;
  String mealAdviceId=StringUtils.EMPTY;
  if (dosage != null) {
    drugName=dosage.getDrugName();
    dosageTypeId=dosage.getDosageType();
    morningTime=dosage.getMorningTime();
    eveningTime=dosage.getEveningTime();
    offsetDays=dosage.getOffsetDays();
    startDate=DateUtils.formatDate(dosage.getStartDate(),"String_Node_Str");
    advice=dosage.getAdvice();
    mealAdviceId=dosage.getMealAdvice();
  }
  row.add(drugName);
  row.add(dosageTypeId);
  row.add(morningTime);
  row.add(eveningTime);
  row.add(offsetDays);
  row.add(startDate);
  row.add(advice);
  row.add(mealAdviceId);
}

Fixed version (ground truth):
private void populateDosage(List<Object> row,DrugDosageContract dosage){
  String drugName=StringUtils.EMPTY;
  String dosageTypeId=StringUtils.EMPTY;
  String morningTime=StringUtils.EMPTY;
  String eveningTime=StringUtils.EMPTY;
  Integer offsetDays=null;
  String startDate=null;
  String advice=StringUtils.EMPTY;
  String mealAdviceId=StringUtils.EMPTY;
  if (dosage != null) {
    drugName=dosage.getDrugName();
    dosageTypeId=dosage.getDosageType();
    morningTime=dosage.getMorningTime();
    eveningTime=dosage.getEveningTime();
    offsetDays=dosage.getOffsetDays();
    startDate=format(dosage.getStartDate(),"String_Node_Str");
    advice=dosage.getAdvice();
    mealAdviceId=dosage.getMealAdvice();
  }
  row.add(drugName);
  row.add(dosageTypeId);
  row.add(morningTime);
  row.add(eveningTime);
  row.add(offsetDays);
  row.add(startDate);
  row.add(advice);
  row.add(mealAdviceId);
}
Program: 84759
Project: 84759
Buggy source:
@RequestMapping(value="String_Node_Str",method=RequestMethod.GET) public String downloadSMSReport(DateFilter filter,@RequestParam("String_Node_Str") String clinicName,@RequestParam("String_Node_Str") String externalId,@RequestParam("String_Node_Str") String type,Model model){
  if (filter.isMoreThanOneYear()) {
    return error(model,"String_Node_Str");
  }
 else {
    return format("String_Node_Str",clinicName,externalId,filter.getStartDate().toString("String_Node_Str"),filter.getEndDate().toString("String_Node_Str"),type);
  }
}

Fixed version (ground truth):
@RequestMapping(value="String_Node_Str",method=RequestMethod.GET) public String downloadSMSReport(DateFilter filter,@RequestParam("String_Node_Str") String clinicName,@RequestParam("String_Node_Str") String externalId,@RequestParam("String_Node_Str") String type,Model model){
  if (filter.isMoreThanOneYear()) {
    return error(model,type + "String_Node_Str");
  }
 else {
    return format("String_Node_Str",clinicName,externalId,filter.getStartDate().toString("String_Node_Str"),filter.getEndDate().toString("String_Node_Str"),type);
  }
}
Program: 84761
Project: 84761
Buggy source:
private List<String> timeSlots(DateTime startDate,DateTime endDate){
  final List<String> allTimeSlots=new ArrayList<String>();
  while (startDate.isBefore(endDate)) {
    LocalTime slotStartTime=startDate.toLocalTime();
    LocalTime slotEndTime=startDate.toLocalTime().plusMinutes(slot_duration_in_mins).minusMinutes(1);
    int allottedCount=allCallTimeSlots.countOfPatientsAllottedForSlot(slotStartTime,slotEndTime);
    if (allottedCount < max_patients_per_slot) {
      allTimeSlots.add(slotStartTime.toString("String_Node_Str"));
    }
    startDate=startDate.plusMinutes(slot_duration_in_mins);
  }
  return allTimeSlots;
}

Fixed version (ground truth):
private List<String> timeSlots(DateTime startDate,DateTime endDate){
  final AllottedSlots allottedSlots=allCallTimeSlots.getAllottedSlots();
  final List<String> allTimeSlots=new ArrayList<String>();
  while (startDate.isBefore(endDate)) {
    LocalTime slotStartTime=startDate.toLocalTime();
    LocalTime slotEndTime=startDate.toLocalTime().plusMinutes(slot_duration_in_mins).minusMinutes(1);
    int allottedCount=allottedSlots.numberOfPatientsAllottedPerSlot(slotStartTime,slotEndTime);
    if (allottedCount < max_patients_per_slot) {
      allTimeSlots.add(slotStartTime.toString("String_Node_Str"));
    }
    startDate=startDate.plusMinutes(slot_duration_in_mins);
  }
  return allTimeSlots;
}
Program: 84762
Project: 84762
Buggy source:
@Test public void shouldGetAllEveningTimeSlots(){
  when(allCallTimeSlots.countOfPatientsAllottedForSlot(Matchers.<LocalTime>any(),Matchers.<LocalTime>any())).thenReturn(2);
  final List<String> eveningTimeSlots=callTimeSlotService.availableEveningSlots();
  assertEquals(48,eveningTimeSlots.size());
}

Fixed version (ground truth):
@Test public void shouldGetAllEveningTimeSlots(){
  when(allCallTimeSlots.getAllottedSlots()).thenReturn(new AllottedSlots());
  final List<String> eveningTimeSlots=callTimeSlotService.availableEveningSlots();
  assertEquals(48,eveningTimeSlots.size());
}
Program: 84763
Project: 84763
Buggy source:
@Test public void shouldGetAllAvailableEveningTimeSlots(){
  when(allCallTimeSlots.countOfPatientsAllottedForSlot(Matchers.<LocalTime>any(),Matchers.<LocalTime>any())).thenReturn(2,10,10,10,10,2,10,10,2,10);
  final List<String> timeSlots=callTimeSlotService.availableEveningSlots();
  assertEquals(3,timeSlots.size());
  assertEquals("String_Node_Str",timeSlots.get(0));
  assertEquals("String_Node_Str",timeSlots.get(1));
  assertEquals("String_Node_Str",timeSlots.get(2));
}

Fixed version (ground truth):
@Test public void shouldGetAllAvailableEveningTimeSlots(){
  AllottedSlot fullNoonSlot=new AllottedSlot(DateUtil.now().withTime(12,0,0,0),10);
  AllottedSlot almostFull1230PMSlot=new AllottedSlot(DateUtil.now().withTime(12,30,0,0),9);
  AllottedSlot full1245PMSlot=new AllottedSlot(DateUtil.now().withTime(12,45,0,0),10);
  AllottedSlots allottedSlots=new AllottedSlots(Arrays.asList(fullNoonSlot,almostFull1230PMSlot,full1245PMSlot));
  when(allCallTimeSlots.getAllottedSlots()).thenReturn(allottedSlots);
  final List<String> timeSlots=callTimeSlotService.availableEveningSlots();
  assertEquals(46,timeSlots.size());
  assertEquals("String_Node_Str",timeSlots.get(0));
  assertEquals("String_Node_Str",timeSlots.get(1));
  assertEquals("String_Node_Str",timeSlots.get(2));
  assertEquals("String_Node_Str",timeSlots.get(3));
}
Program: 84764
Project: 84764
Buggy source:
@Test public void shouldGetAllMorningTimeSlots(){
  when(allCallTimeSlots.countOfPatientsAllottedForSlot(Matchers.<LocalTime>any(),Matchers.<LocalTime>any())).thenReturn(2);
  final List<String> morningTimeSlots=callTimeSlotService.availableMorningSlots();
  assertEquals(48,morningTimeSlots.size());
}

Fixed version (ground truth):
@Test public void shouldGetAllMorningTimeSlots(){
  when(allCallTimeSlots.getAllottedSlots()).thenReturn(new AllottedSlots());
  final List<String> morningTimeSlots=callTimeSlotService.availableMorningSlots();
  assertEquals(48,morningTimeSlots.size());
}
Program: 84765
Project: 84765
Buggy source:
@Test public void shouldGetAllAvailableMorningTimeSlots(){
  when(allCallTimeSlots.countOfPatientsAllottedForSlot(Matchers.<LocalTime>any(),Matchers.<LocalTime>any())).thenReturn(2,10,10,10,10,2,10,10,2,10);
  final List<String> timeSlots=callTimeSlotService.availableMorningSlots();
  assertEquals(3,timeSlots.size());
  assertEquals("String_Node_Str",timeSlots.get(0));
  assertEquals("String_Node_Str",timeSlots.get(1));
  assertEquals("String_Node_Str",timeSlots.get(2));
}

Fixed version (ground truth):
@Test public void shouldGetAllAvailableMorningTimeSlots(){
  AllottedSlot fullMidnightSlot=new AllottedSlot(DateUtil.now().withTime(0,0,0,0),10);
  AllottedSlot full1AMSlot=new AllottedSlot(DateUtil.now().withTime(1,0,0,0),10);
  AllottedSlots allottedSlots=new AllottedSlots(Arrays.asList(fullMidnightSlot,full1AMSlot));
  when(allCallTimeSlots.getAllottedSlots()).thenReturn(allottedSlots);
  final List<String> timeSlots=callTimeSlotService.availableMorningSlots();
  assertEquals(46,timeSlots.size());
  assertEquals("String_Node_Str",timeSlots.get(0));
  assertEquals("String_Node_Str",timeSlots.get(1));
  assertEquals("String_Node_Str",timeSlots.get(2));
  assertEquals("String_Node_Str",timeSlots.get(3));
}
Program: 84766
Project: 84766
Buggy source:
private LocalDate computeFirstWeekStartDate(DateTime fromDate){
  LocalDate startDateForFirstWeek=fourDayRecallDateService.treatmentWeekStartDate(fromDate.toLocalDate(),patient,treatmentAdvice);
  DateTime recallDateTimeForFirstWeek=fourDayRecallDateService.nextRecallOn(startDateForFirstWeek,patient);
  LocalDate nextWeekStartDate=null;
  if (DateUtil.isOnOrBefore(DateUtil.newDate(treatmentAdvice.getStartDate()),startDateForFirstWeek) && !recallDateTimeForFirstWeek.plusDays(daysToRetry).isBefore(fromDate) && !recallDateTimeForFirstWeek.isAfter(toDate)) {
    nextWeekStartDate=startDateForFirstWeek;
  }
  if (recallDateTimeForFirstWeek.plusDays(daysToRetry).isBefore(fromDate) && startDateForFirstWeek.plusWeeks(1).isBefore(toDate.toLocalDate())) {
    nextWeekStartDate=computeNextWeekStartDate(startDateForFirstWeek);
  }
  return nextWeekStartDate;
}

Fixed version (ground truth):
private LocalDate computeFirstWeekStartDate(DateTime fromDate){
  LocalDate startDateForFirstWeek=fourDayRecallDateService.treatmentWeekStartDate(fromDate.toLocalDate(),patient,treatmentAdvice);
  DateTime recallDateTimeForFirstWeek=fourDayRecallDateService.nextRecallOn(startDateForFirstWeek,patient);
  LocalDate nextWeekStartDate=null;
  if (DateUtil.isOnOrBefore(DateUtil.newDateTime(treatmentAdvice.getStartDate()),DateUtil.newDateTime(startDateForFirstWeek)) && !recallDateTimeForFirstWeek.plusDays(daysToRetry).isBefore(fromDate) && !recallDateTimeForFirstWeek.isAfter(toDate)) {
    nextWeekStartDate=startDateForFirstWeek;
  }
  if (recallDateTimeForFirstWeek.plusDays(daysToRetry).isBefore(fromDate) && startDateForFirstWeek.plusWeeks(1).isBefore(toDate.toLocalDate())) {
    nextWeekStartDate=computeNextWeekStartDate(startDateForFirstWeek);
  }
  return nextWeekStartDate;
}
Program: 84767
Project: 84767
Buggy source:
public void createCallLogs(MyWebClient webClient,TAMADateTimeService tamaDateTimeService,DateTime startDate,int numberOfDays){
  List<Patient> patients=allPatients.getAll();
  for (int dayNumber=1; dayNumber <= numberOfDays; dayNumber++) {
    for (    Patient patient : patients) {
      patientConfirmsDoseAsTaken(webClient,patient);
    }
    DateTime today=startDate.plusDays(1);
    tamaDateTimeService.adjustDateTime(today);
  }
}

Fixed version (ground truth):
public void createCallLogs(MyWebClient webClient,TAMADateTimeService tamaDateTimeService,DateTime startDate,int numberOfDays){
  List<Patient> patients=allPatients.getAll();
  for (int dayNumber=1; dayNumber <= numberOfDays; dayNumber++) {
    for (    Patient patient : patients) {
      patientConfirmsDoseAsTaken(webClient,patient);
    }
    startDate=startDate.plusDays(1);
    tamaDateTimeService.adjustDateTime(startDate);
  }
}
Program: 84768
Project: 84768
Buggy source:
private Patient createActivePatient(MedicalHistory medicalHistory,Clinic clinic){
  Gender gender=allGenders.getAll().get(0);
  Patient patient=PatientBuilder.startRecording().withDefaults().withMedicalHistory(medicalHistory).withGender(gender).withIVRLanguage(allIVRLanguages.getAll().get(0)).build();
  patientController.create(patient,bindingResult,uiModel,request);
  patientController.activate(patient.getId(),uiModel,request);
  return patient;
}

Fixed version (ground truth):
private Patient createActivePatient(MedicalHistory medicalHistory,LocalDate today){
  Gender gender=allGenders.getAll().get(0);
  Patient patient=PatientBuilder.startRecording().withDefaults().withMedicalHistory(medicalHistory).withGender(gender).withIVRLanguage(allIVRLanguages.getAll().get(0)).withRegistrationDate(today).build();
  patientController.create(patient,bindingResult,uiModel,request);
  patientController.activate(patient.getId(),uiModel,request);
  return patient;
}
Program: 84769
Project: 84769
Buggy source:
public void createPatients(LocalDate today,int numberOfPatients){
  List<Clinic> clinics=allClinics.getAll();
  assertTrue("String_Node_Str",clinics.size() > 0);
  LocalTime doseTime=new LocalTime(10,0);
  MedicalHistory medicalHistory=MedicalHistoryBuilder.startRecording().withDefaults().build();
  for (int patientsCreated=0; patientsCreated < numberOfPatients; patientsCreated++) {
    DateTime timeOfRegistration=DateUtil.newDateTime(today,10,0,0);
    doseTime=getFreeSlotTime(doseTime,patientsCreated);
    Clinic clinic=clinics.get(patientsCreated % clinics.size());
    login(clinic);
    Patient patient=createActivePatient(medicalHistory,clinic);
    recordFirstClinicVisit(patient,today,doseTime,timeOfRegistration);
    log.info("String_Node_Str" + patient.getPatientId() + "String_Node_Str"+ clinic.getName()+ "String_Node_Str"+ doseTime);
  }
}

Fixed version (ground truth):
public void createPatients(LocalDate today,int numberOfPatients){
  List<Clinic> clinics=allClinics.getAll();
  assertTrue("String_Node_Str",clinics.size() > 0);
  LocalTime doseTime=new LocalTime(10,0);
  MedicalHistory medicalHistory=MedicalHistoryBuilder.startRecording().withDefaults().build();
  for (int patientsCreated=0; patientsCreated < numberOfPatients; patientsCreated++) {
    DateTime timeOfRegistration=DateUtil.newDateTime(today,10,0,0);
    doseTime=getFreeSlotTime(doseTime,patientsCreated);
    Clinic clinic=clinics.get(patientsCreated % clinics.size());
    login(clinic);
    Patient patient=createActivePatient(medicalHistory,today);
    recordFirstClinicVisit(patient,today,doseTime,timeOfRegistration);
    log.info("String_Node_Str" + patient.getPatientId() + "String_Node_Str"+ clinic.getName()+ "String_Node_Str"+ doseTime);
  }
}
Program: 84770
Project: 84770
Buggy source:
private String redirectToCreateFormUrl(String clinicVisitId,String patientId,HttpServletRequest httpServletRequest){
  String queryParameters="String_Node_Str" + patientId + "String_Node_Str"+ clinicVisitId;
  return "String_Node_Str" + encodeUrlPathSegment(queryParameters,httpServletRequest);
}

Fixed version (ground truth):
public static String redirectToCreateFormUrl(String clinicVisitId,String patientId){
  String queryParameters="String_Node_Str" + patientId + "String_Node_Str"+ clinicVisitId;
  return "String_Node_Str" + queryParameters;
}
Program: 84771
Project: 84771
Buggy source:
@RequestMapping(params="String_Node_Str",method=RequestMethod.GET) public String createForm(@RequestParam(value="String_Node_Str",required=true) String patientDocId,@RequestParam(value="String_Node_Str",required=true) String clinicVisitId,Model uiModel,HttpServletRequest httpServletRequest){
  ClinicVisit clinicVisit=allClinicVisits.get(patientDocId,clinicVisitId);
  final String treatmentAdviceId=clinicVisit.getTreatmentAdviceId();
  TreatmentAdvice adviceForPatient=null;
  if (treatmentAdviceId != null)   adviceForPatient=allTreatmentAdvices.get(treatmentAdviceId);
  if (adviceForPatient == null)   adviceForPatient=allTreatmentAdvices.currentTreatmentAdvice(patientDocId);
  if (adviceForPatient != null) {
    treatmentAdviceController.show(adviceForPatient.getId(),uiModel);
    final boolean wasVisitDetailsEdited=(clinicVisit.getTreatmentAdviceId() != null || !clinicVisit.getLabResultIds().isEmpty() || clinicVisit.getVitalStatisticsId() != null || clinicVisit.getReportedOpportunisticInfectionsId() != null);
    if (wasVisitDetailsEdited)     return redirectToShowClinicVisitUrl(clinicVisitId,patientDocId,httpServletRequest);
  }
 else {
    treatmentAdviceController.createForm(patientDocId,uiModel);
  }
  uiModel.addAttribute("String_Node_Str",patientDocId);
  uiModel.addAttribute("String_Node_Str",new ClinicVisitUIModel(clinicVisit));
  labResultsController.createForm(patientDocId,uiModel);
  vitalStatisticsController.createForm(patientDocId,uiModel);
  opportunisticInfectionsController.createForm(clinicVisit,uiModel);
  return "String_Node_Str";
}

Fixed version (ground truth):
@RequestMapping(params="String_Node_Str",method=RequestMethod.GET) public String createForm(@RequestParam(value="String_Node_Str",required=true) String patientDocId,@RequestParam(value="String_Node_Str",required=true) String clinicVisitId,Model uiModel,HttpServletRequest httpServletRequest){
  ClinicVisit clinicVisit=allClinicVisits.get(patientDocId,clinicVisitId);
  final String treatmentAdviceId=clinicVisit.getTreatmentAdviceId();
  TreatmentAdvice adviceForPatient=null;
  if (treatmentAdviceId != null)   adviceForPatient=allTreatmentAdvices.get(treatmentAdviceId);
  if (adviceForPatient == null)   adviceForPatient=allTreatmentAdvices.currentTreatmentAdvice(patientDocId);
  if (adviceForPatient != null) {
    treatmentAdviceController.show(adviceForPatient.getId(),uiModel);
    final boolean wasVisitDetailsEdited=(clinicVisit.getVisitDate() != null);
    if (wasVisitDetailsEdited)     return redirectToShowClinicVisitUrl(clinicVisitId,patientDocId,httpServletRequest);
  }
 else {
    treatmentAdviceController.createForm(patientDocId,uiModel);
  }
  uiModel.addAttribute("String_Node_Str",patientDocId);
  uiModel.addAttribute("String_Node_Str",new ClinicVisitUIModel(clinicVisit));
  labResultsController.createForm(patientDocId,uiModel);
  vitalStatisticsController.createForm(patientDocId,uiModel);
  opportunisticInfectionsController.createForm(clinicVisit,uiModel);
  return "String_Node_Str";
}
Program: 84773
Project: 84773
Buggy source:
@RequestMapping(method=RequestMethod.POST) public String changeRegimen(String existingTreatmentAdviceId,String discontinuationReason,TreatmentAdvice treatmentAdvice,String clinicVisitId,Model uiModel,HttpServletRequest httpServletRequest){
  uiModel.asMap().clear();
  fixTimeString(treatmentAdvice);
  String treatmentAdviceId=existingTreatmentAdviceId;
  try {
    treatmentAdviceId=treatmentAdviceService.changeRegimen(existingTreatmentAdviceId,discontinuationReason,treatmentAdvice);
    allClinicVisits.changeRegimen(treatmentAdvice.getPatientId(),clinicVisitId,treatmentAdviceId);
    return "String_Node_Str" + encodeUrlPathSegment(clinicVisitId,httpServletRequest) + "String_Node_Str"+ treatmentAdvice.getPatientId();
  }
 catch (  RuntimeException e) {
    httpServletRequest.setAttribute("String_Node_Str","String_Node_Str");
    return "String_Node_Str" + treatmentAdviceId + "String_Node_Str"+ clinicVisitId+ "String_Node_Str"+ treatmentAdvice.getPatientId();
  }
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.POST) public String changeRegimen(String existingTreatmentAdviceId,String discontinuationReason,TreatmentAdvice treatmentAdvice,String clinicVisitId,Model uiModel,HttpServletRequest httpServletRequest){
  uiModel.asMap().clear();
  fixTimeString(treatmentAdvice);
  String treatmentAdviceId=existingTreatmentAdviceId;
  try {
    treatmentAdviceId=treatmentAdviceService.changeRegimen(existingTreatmentAdviceId,discontinuationReason,treatmentAdvice);
    allClinicVisits.changeRegimen(treatmentAdvice.getPatientId(),clinicVisitId,treatmentAdviceId);
    return ClinicVisitsController.redirectToCreateFormUrl(clinicVisitId,treatmentAdvice.getPatientId());
  }
 catch (  RuntimeException e) {
    httpServletRequest.setAttribute("String_Node_Str","String_Node_Str" + e.getMessage());
    return "String_Node_Str" + treatmentAdviceId + "String_Node_Str"+ clinicVisitId+ "String_Node_Str"+ treatmentAdvice.getPatientId();
  }
}
Program: 84774
Project: 84774
Buggy source:
private ReportedOpportunisticInfections buildReportedOpportunisticInfections(OpportunisticInfectionsUIModel opportunisticInfectionsUIModel){
  ReportedOpportunisticInfections reportedOpportunisticInfections=new ReportedOpportunisticInfections();
  reportedOpportunisticInfections.setPatientId(opportunisticInfectionsUIModel.getPatientId());
  reportedOpportunisticInfections.setCaptureDate(DateUtil.today());
  for (  OIStatus oiStatus : opportunisticInfectionsUIModel.getInfections()) {
    if (oiStatus.getReported()) {
      String nameOfInfection=oiStatus.getOpportunisticInfection();
      List<OpportunisticInfection> oiList=(List<OpportunisticInfection>)CollectionUtils.select(allOpportunisticInfections.getAll(),withName(nameOfInfection));
      reportedOpportunisticInfections.addOpportunisticInfection(oiList.get(0));
    }
  }
  if (opportunisticInfectionsUIModel.getOtherDetails() != null && !opportunisticInfectionsUIModel.getOtherDetails().isEmpty()) {
    reportedOpportunisticInfections.setOtherOpportunisticInfectionDetails(opportunisticInfectionsUIModel.getOtherDetails());
  }
  return reportedOpportunisticInfections;
}

Fixed version (ground truth):
private ReportedOpportunisticInfections buildReportedOpportunisticInfections(OpportunisticInfectionsUIModel opportunisticInfectionsUIModel){
  ReportedOpportunisticInfections reportedOpportunisticInfections=new ReportedOpportunisticInfections();
  reportedOpportunisticInfections.setPatientId(opportunisticInfectionsUIModel.getPatientId());
  reportedOpportunisticInfections.setCaptureDate(DateUtil.today());
  boolean otherInfectionReported=false;
  for (  OIStatus oiStatus : opportunisticInfectionsUIModel.getInfections()) {
    if (oiStatus.getReported()) {
      String nameOfInfection=oiStatus.getOpportunisticInfection();
      if (OTHER.equals(nameOfInfection))       otherInfectionReported=true;
      List<OpportunisticInfection> oiList=(List<OpportunisticInfection>)CollectionUtils.select(allOpportunisticInfections.getAll(),withName(nameOfInfection));
      reportedOpportunisticInfections.addOpportunisticInfection(oiList.get(0));
    }
  }
  if (otherInfectionReported && opportunisticInfectionsUIModel.getOtherDetails() != null && !opportunisticInfectionsUIModel.getOtherDetails().isEmpty()) {
    reportedOpportunisticInfections.setOtherOpportunisticInfectionDetails(opportunisticInfectionsUIModel.getOtherDetails());
  }
  return reportedOpportunisticInfections;
}
Program: 84775
Project: 84775
Buggy source:
private OpportunisticInfectionsUIModel buildModelWithNoInfectionsReported(){
  return OpportunisticInfectionsUIModel.newDefault(clinicVisit,allOpportunisticInfections.getAll());
}

Fixed version (ground truth):
protected OpportunisticInfectionsUIModel buildModelWithNoInfectionsReported(){
  return OpportunisticInfectionsUIModel.newDefault(clinicVisit,allOpportunisticInfections.getAll());
}
Program: 84776
Project: 84776
Buggy source:
@Test public void shouldCreateReportedOpportunisticInfections() throws Exception {
  opportunisticInfectionsController.create(buildModelWithInfectionReported(true),bindingResult,uiModel,request);
  ArgumentCaptor<ReportedOpportunisticInfections> argumentCaptor=ArgumentCaptor.forClass(ReportedOpportunisticInfections.class);
  verify(allReportedOpportunisticInfections).add(argumentCaptor.capture());
  ReportedOpportunisticInfections reportedOpportunisticInfections=argumentCaptor.getValue();
  assertEquals(DateUtil.today(),reportedOpportunisticInfections.getCaptureDate());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getPatientId());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getOtherOpportunisticInfectionDetails());
  assertEquals(1,reportedOpportunisticInfections.getOpportunisticInfectionIds().size());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getOpportunisticInfectionIds().get(0));
}

Fixed version (ground truth):
@Test public void shouldCreateReportedOpportunisticInfections() throws Exception {
  opportunisticInfectionsController.create(buildModelWithInfectionReported(true),bindingResult,uiModel,request);
  ArgumentCaptor<ReportedOpportunisticInfections> argumentCaptor=ArgumentCaptor.forClass(ReportedOpportunisticInfections.class);
  verify(allReportedOpportunisticInfections).add(argumentCaptor.capture());
  ReportedOpportunisticInfections reportedOpportunisticInfections=argumentCaptor.getValue();
  assertEquals(DateUtil.today(),reportedOpportunisticInfections.getCaptureDate());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getPatientId());
  assertEquals(2,reportedOpportunisticInfections.getOpportunisticInfectionIds().size());
  assertEquals(INFECTION_ID,reportedOpportunisticInfections.getOpportunisticInfectionIds().get(0));
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getOpportunisticInfectionIds().get(1));
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getOtherOpportunisticInfectionDetails());
}
Program: 84777
Project: 84777
Buggy source:
@Test public void shouldCreateReportedOpportunisticWithOutOtherDetailsIfNotPresent() throws Exception {
  opportunisticInfectionsController.create(buildModelWithInfectionReported(false),bindingResult,uiModel,request);
  ArgumentCaptor<ReportedOpportunisticInfections> argumentCaptor=ArgumentCaptor.forClass(ReportedOpportunisticInfections.class);
  verify(allReportedOpportunisticInfections).add(argumentCaptor.capture());
  ReportedOpportunisticInfections reportedOpportunisticInfections=argumentCaptor.getValue();
  assertEquals(DateUtil.today(),reportedOpportunisticInfections.getCaptureDate());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getPatientId());
  assertEquals(1,reportedOpportunisticInfections.getOpportunisticInfectionIds().size());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getOpportunisticInfectionIds().get(0));
  assertNull(reportedOpportunisticInfections.getOtherOpportunisticInfectionDetails());
}

Fixed version (ground truth):
@Test public void shouldCreateReportedOpportunisticWithOutOtherDetailsIfNotPresent() throws Exception {
  opportunisticInfectionsController.create(buildModelWithInfectionReported(false),bindingResult,uiModel,request);
  ArgumentCaptor<ReportedOpportunisticInfections> argumentCaptor=ArgumentCaptor.forClass(ReportedOpportunisticInfections.class);
  verify(allReportedOpportunisticInfections).add(argumentCaptor.capture());
  ReportedOpportunisticInfections reportedOpportunisticInfections=argumentCaptor.getValue();
  assertEquals(DateUtil.today(),reportedOpportunisticInfections.getCaptureDate());
  assertEquals("String_Node_Str",reportedOpportunisticInfections.getPatientId());
  assertEquals(1,reportedOpportunisticInfections.getOpportunisticInfectionIds().size());
  assertEquals(INFECTION_ID,reportedOpportunisticInfections.getOpportunisticInfectionIds().get(0));
  assertNull(reportedOpportunisticInfections.getOtherOpportunisticInfectionDetails());
}
Program: 84778
Project: 84778
Buggy source:
@Test public void shouldNotAddAnyDataIfNewDataIsEmpty(){
  HttpServletRequest httpServletRequest=mock(HttpServletRequest.class);
  ReportedOpportunisticInfections updatedOIData=new ReportedOpportunisticInfections();
  updatedOIData.setPatientId(PATIENT_ID);
  OpportunisticInfectionsUIModel opportunisticInfectionsUIModel=OpportunisticInfectionsUIModel.create(clinicVisit,updatedOIData,allOpportunisticInfections.getAll());
  opportunisticInfectionsController.update(opportunisticInfectionsUIModel,httpServletRequest);
  verify(allReportedOpportunisticInfections,never()).add(Matchers.<ReportedOpportunisticInfections>any());
  verify(allClinicVisits).updateOpportunisticInfections(PATIENT_ID,CLINIC_VISIT_ID,null);
}

Fixed version (ground truth):
@Test public void shouldNotAddAnyDataIfNewDataIsEmpty(){
  ReportedOpportunisticInfections updatedOIData=new ReportedOpportunisticInfections();
  updatedOIData.setPatientId(PATIENT_ID);
  OpportunisticInfectionsUIModel opportunisticInfectionsUIModel=OpportunisticInfectionsUIModel.create(clinicVisit,updatedOIData,allOpportunisticInfections.getAll());
  opportunisticInfectionsController.update(opportunisticInfectionsUIModel,httpServletRequest);
  verify(allReportedOpportunisticInfections,never()).add(Matchers.<ReportedOpportunisticInfections>any());
  verify(allClinicVisits).updateOpportunisticInfections(PATIENT_ID,CLINIC_VISIT_ID,null);
}
Program: 84779
Project: 84779
Buggy source:
private OpportunisticInfectionsUIModel buildModelWithInfectionReported(boolean otherDetailsPresent){
  ReportedOpportunisticInfections reportedOpportunisticInfections=new ReportedOpportunisticInfections();
  reportedOpportunisticInfections.addOpportunisticInfection(opportunisticInfection);
  OpportunisticInfectionsUIModel opportunisticInfectionsUIModel=OpportunisticInfectionsUIModel.create(clinicVisit,reportedOpportunisticInfections,allOpportunisticInfections.getAll());
  if (otherDetailsPresent)   opportunisticInfectionsUIModel.setOtherDetails("String_Node_Str");
 else   opportunisticInfectionsUIModel.setOtherDetails("String_Node_Str");
  return opportunisticInfectionsUIModel;
}

Fixed version (ground truth):
protected OpportunisticInfectionsUIModel buildModelWithInfectionReported(boolean otherDetailsPresent){
  ReportedOpportunisticInfections reportedOpportunisticInfections=new ReportedOpportunisticInfections();
  reportedOpportunisticInfections.addOpportunisticInfection(opportunisticInfection);
  if (otherDetailsPresent)   reportedOpportunisticInfections.addOpportunisticInfection(otherOpportunisticInfection);
  OpportunisticInfectionsUIModel opportunisticInfectionsUIModel=OpportunisticInfectionsUIModel.create(clinicVisit,reportedOpportunisticInfections,allOpportunisticInfections.getAll());
  if (otherDetailsPresent)   opportunisticInfectionsUIModel.setOtherDetails("String_Node_Str");
 else   opportunisticInfectionsUIModel.setOtherDetails("String_Node_Str");
  return opportunisticInfectionsUIModel;
}
Program: 84780
Project: 84780
Buggy source:
@Before public void setUp(){
  initMocks(this);
  opportunisticInfectionsController=new OpportunisticInfectionsController(allClinicVisits,allReportedOpportunisticInfections,allOpportunisticInfections);
  opportunisticInfection=new OpportunisticInfection();
  opportunisticInfection.setName(INFECTION_NAME);
  opportunisticInfection.setId(INFECTION_ID);
  when(allOpportunisticInfections.getAll()).thenReturn(Arrays.asList(opportunisticInfection));
  patient=new Patient();
  patient.setId(PATIENT_ID);
  visit=new VisitResponse();
  visit.setName(CLINIC_VISIT_ID).addVisitData(ClinicVisit.REPORTED_OPPORTUNISTIC_INFECTIONS,REPORT_OI_ID);
  clinicVisit=new ClinicVisit(patient,visit);
  when(allClinicVisits.get(PATIENT_ID,CLINIC_VISIT_ID)).thenReturn(clinicVisit);
  reportedOpportunisticInfections=new ReportedOpportunisticInfections();
  reportedOpportunisticInfections.addOpportunisticInfection(opportunisticInfection);
  when(allReportedOpportunisticInfections.get(REPORT_OI_ID)).thenReturn(reportedOpportunisticInfections);
}

Fixed version (ground truth):
@Before public void setUp(){
  initMocks(this);
  opportunisticInfectionsController=new OpportunisticInfectionsController(allClinicVisits,allReportedOpportunisticInfections,allOpportunisticInfections);
  opportunisticInfection=new OpportunisticInfection();
  opportunisticInfection.setName(ANEMIA);
  opportunisticInfection.setId(INFECTION_ID);
  otherOpportunisticInfection=new OpportunisticInfection();
  otherOpportunisticInfection.setName("String_Node_Str");
  otherOpportunisticInfection.setId("String_Node_Str");
  ArrayList<OpportunisticInfection> opportunisticInfections=new ArrayList<OpportunisticInfection>();
  opportunisticInfections.add(opportunisticInfection);
  opportunisticInfections.add(otherOpportunisticInfection);
  when(allOpportunisticInfections.getAll()).thenReturn(opportunisticInfections);
  patient=new Patient();
  patient.setId(PATIENT_ID);
  visit=new VisitResponse();
  visit.setName(CLINIC_VISIT_ID).addVisitData(ClinicVisit.REPORTED_OPPORTUNISTIC_INFECTIONS,REPORT_OI_ID);
  clinicVisit=new ClinicVisit(patient,visit);
  when(allClinicVisits.get(PATIENT_ID,CLINIC_VISIT_ID)).thenReturn(clinicVisit);
  reportedOpportunisticInfections=new ReportedOpportunisticInfections();
  reportedOpportunisticInfections.addOpportunisticInfection(opportunisticInfection);
  when(allReportedOpportunisticInfections.get(REPORT_OI_ID)).thenReturn(reportedOpportunisticInfections);
}
Program: 84781
Project: 84781
Buggy source:
@Test public void shouldAddNewData(){
  HttpServletRequest httpServletRequest=mock(HttpServletRequest.class);
  OpportunisticInfection anemia=OpportunisticInfection.newOpportunisticInfection("String_Node_Str");
  anemia.setId("String_Node_Str");
  ArrayList<OpportunisticInfection> infections=new ArrayList<OpportunisticInfection>();
  infections.add(anemia);
  infections.add(opportunisticInfection);
  when(allOpportunisticInfections.getAll()).thenReturn(infections);
  ReportedOpportunisticInfections updatedOIData=new ReportedOpportunisticInfections();
  updatedOIData.setPatientId(PATIENT_ID);
  updatedOIData.addOpportunisticInfection(anemia);
  OpportunisticInfectionsUIModel opportunisticInfectionsUIModel=OpportunisticInfectionsUIModel.create(clinicVisit,updatedOIData,allOpportunisticInfections.getAll());
  opportunisticInfectionsController.update(opportunisticInfectionsUIModel,httpServletRequest);
  ArgumentCaptor<ReportedOpportunisticInfections> argumentCaptor=ArgumentCaptor.forClass(ReportedOpportunisticInfections.class);
  verify(allReportedOpportunisticInfections).add(argumentCaptor.capture());
  ReportedOpportunisticInfections opportunisticInfections=argumentCaptor.getValue();
  assertEquals(1,opportunisticInfections.getOpportunisticInfectionIds().size());
  assertEquals("String_Node_Str",opportunisticInfections.getOpportunisticInfectionIds().get(0));
  assertEquals(PATIENT_ID,opportunisticInfections.getPatientId());
  verify(allClinicVisits).updateOpportunisticInfections(eq(PATIENT_ID),eq(CLINIC_VISIT_ID),Matchers.<String>any());
}

Fixed version (ground truth):
@Test public void shouldAddNewData(){
  OpportunisticInfection anemia=OpportunisticInfection.newOpportunisticInfection("String_Node_Str");
  anemia.setId("String_Node_Str");
  ArrayList<OpportunisticInfection> infections=new ArrayList<OpportunisticInfection>();
  infections.add(anemia);
  infections.add(opportunisticInfection);
  when(allOpportunisticInfections.getAll()).thenReturn(infections);
  ReportedOpportunisticInfections updatedOIData=new ReportedOpportunisticInfections();
  updatedOIData.setPatientId(PATIENT_ID);
  updatedOIData.addOpportunisticInfection(anemia);
  OpportunisticInfectionsUIModel opportunisticInfectionsUIModel=OpportunisticInfectionsUIModel.create(clinicVisit,updatedOIData,allOpportunisticInfections.getAll());
  opportunisticInfectionsController.update(opportunisticInfectionsUIModel,httpServletRequest);
  ArgumentCaptor<ReportedOpportunisticInfections> argumentCaptor=ArgumentCaptor.forClass(ReportedOpportunisticInfections.class);
  verify(allReportedOpportunisticInfections).add(argumentCaptor.capture());
  ReportedOpportunisticInfections opportunisticInfections=argumentCaptor.getValue();
  assertEquals(1,opportunisticInfections.getOpportunisticInfectionIds().size());
  assertEquals("String_Node_Str",opportunisticInfections.getOpportunisticInfectionIds().get(0));
  assertEquals(PATIENT_ID,opportunisticInfections.getPatientId());
  verify(allClinicVisits).updateOpportunisticInfections(eq(PATIENT_ID),eq(CLINIC_VISIT_ID),Matchers.<String>any());
}
Program: 84782
Project: 84782
Buggy source:
@Test public void shouldReturnEmptyLabResultsWhenVisitHasNoLabResults() throws Exception {
  ClinicVisit visit=new ClinicVisit(new Visit(),new Appointment());
  assertNotNull(visit.getLabResultIds());
}

Fixed version (ground truth):
@Test public void shouldReturnEmptyLabResultsWhenVisitHasNoLabResults() throws Exception {
  ClinicVisit visit=new ClinicVisit("String_Node_Str",new Visit());
  assertNotNull(visit.getLabResultIds());
}
Program: 84783
Project: 84783
Buggy source:
public ListPatientViewModel(Patient patient){
  this.setId(patient.getId());
  this.setPatientId(patient.getPatientId());
  this.setMobilePhoneNumber(patient.getMobilePhoneNumber());
  this.setGender(patient.getGender());
  this.setClinic(patient.getClinic());
  this.setRegistrationDate(patient.getRegistrationDate());
  this.setStatus(patient.getStatus());
}

Fixed version (ground truth):
public ListPatientViewModel(Patient patient){
  this.setId(patient.getId());
  this.setDateOfBirth(patient.getDateOfBirth());
  this.setDateOfBirthAsDate(patient.getDateOfBirthAsDate());
  this.setPatientId(patient.getPatientId());
  this.setMobilePhoneNumber(patient.getMobilePhoneNumber());
  this.setGender(patient.getGender());
  this.setClinic(patient.getClinic());
  this.setRegistrationDate(patient.getRegistrationDate());
  this.setStatus(patient.getStatus());
}
Program: 84784
Project: 84784
Buggy source:
public void unscheduleFourDayRecallJobs(Patient patient){
  Integer daysToRetry=Integer.valueOf(fourDayRecallProperties.getProperty(TAMAConstants.FOUR_DAY_RECALL_DAYS_TO_RETRY));
  for (int count=0; count <= daysToRetry; count++) {
    motechSchedulerService.unscheduleJob(TAMAConstants.FOUR_DAY_RECALL_SUBJECT,count + patient.getId());
  }
  motechSchedulerService.unscheduleRepeatingJob(TAMAConstants.FOUR_DAY_RECALL_SUBJECT,patient.getId());
  motechSchedulerService.unscheduleJob(TAMAConstants.WEEKLY_FALLING_TREND_AND_ADHERENCE_IN_RED_ALERT_SUBJECT,patient.getId());
}

Fixed version (ground truth):
public void unscheduleFourDayRecallJobs(Patient patient){
  Integer daysToRetry=Integer.valueOf(fourDayRecallProperties.getProperty(TAMAConstants.FOUR_DAY_RECALL_DAYS_TO_RETRY));
  for (int count=0; count <= daysToRetry; count++) {
    motechSchedulerService.unscheduleJob(TAMAConstants.FOUR_DAY_RECALL_SUBJECT,count + patient.getId());
  }
  motechSchedulerService.unscheduleRepeatingJob(TAMAConstants.FOUR_DAY_RECALL_SUBJECT,patient.getId());
  for (int count=0; count <= 2; count++) {
    motechSchedulerService.unscheduleJob(TAMAConstants.WEEKLY_FALLING_TREND_AND_ADHERENCE_IN_RED_ALERT_SUBJECT,count + patient.getId());
  }
}
Program: 84785
Project: 84785
Buggy source:
private Dose computeFirstDose(){
  if (to.isBefore(from))   return null;
  if (from.toLocalDate().isBefore(dosageResponse.getStartDate())) {
    from=DateUtil.newDateTime(dosageResponse.getStartDate(),0,0,0);
  }
  DateTime tentativeFirstDoseDateTime=DateUtil.newDateTime(from.toLocalDate(),dosageResponse.getDosageHour(),dosageResponse.getDosageMinute(),0);
  if (tentativeFirstDoseDateTime.isBefore(from)) {
    tentativeFirstDoseDateTime=tentativeFirstDoseDateTime.plusDays(1);
  }
  return new Dose(dosageResponse,tentativeFirstDoseDateTime.toLocalDate());
}

Fixed version (ground truth):
private Dose computeFirstDose(){
  if (to.isBefore(from))   return null;
  if (from.toLocalDate().isBefore(dosageResponse.getStartDate())) {
    from=DateUtil.newDateTime(dosageResponse.getStartDate(),0,0,0);
  }
  DateTime tentativeFirstDoseDateTime=DateUtil.newDateTime(from.toLocalDate(),dosageResponse.getDosageHour(),dosageResponse.getDosageMinute(),0);
  if (tentativeFirstDoseDateTime.isBefore(from)) {
    tentativeFirstDoseDateTime=tentativeFirstDoseDateTime.plusDays(1);
  }
  if (tentativeFirstDoseDateTime.isAfter(to)) {
    return null;
  }
  return new Dose(dosageResponse,tentativeFirstDoseDateTime.toLocalDate());
}
Program: 84786
Project: 84786
Buggy source:
public void backFillAdherenceForPeriodOfSuspension(String patientId,boolean doseTaken){
  Integer daysToRetry=Integer.valueOf(properties.getProperty(TAMAConstants.FOUR_DAY_RECALL_DAYS_TO_RETRY));
  Patient patient=allPatients.get(patientId);
  TreatmentAdvice treatmentAdvice=allTreatmentAdvices.currentTreatmentAdvice(patientId);
  String treatmentAdviceDocId=treatmentAdvice.getId();
  DateTime resumeDate=DateUtil.now();
  FourDayRecallTimeLine fourDayRecallTimeLine=new FourDayRecallTimeLine(patient,resumeDate,treatmentAdvice,daysToRetry);
  List<LocalDate> weekStartDates=fourDayRecallTimeLine.weekStartDates();
  if (weekStartDates.size() > 0 && allWeeklyAdherenceLogs.findLogsByWeekStartDate(patientId,treatmentAdviceDocId,weekStartDates.get(0)).size() == 0) {
    allWeeklyAdherenceLogs.add(WeeklyAdherenceLog.create(patientId,treatmentAdviceDocId,weekStartDates.get(0),doseTaken ? 0 : PatientPreferences.DAYS_TO_RECALL));
    weekStartDates.remove(0);
  }
  for (  LocalDate date : weekStartDates) {
    allWeeklyAdherenceLogs.add(WeeklyAdherenceLog.create(patientId,treatmentAdviceDocId,date,doseTaken ? 0 : PatientPreferences.DAYS_TO_RECALL));
  }
}

Fixed version (ground truth):
public void backFillAdherenceForPeriodOfSuspension(String patientId,boolean doseTaken){
  Integer daysToRetry=Integer.valueOf(properties.getProperty(TAMAConstants.FOUR_DAY_RECALL_DAYS_TO_RETRY));
  Patient patient=allPatients.get(patientId);
  TreatmentAdvice treatmentAdvice=allTreatmentAdvices.currentTreatmentAdvice(patientId);
  String treatmentAdviceDocId=treatmentAdvice.getId();
  DateTime resumeDate=DateUtil.now();
  FourDayRecallTimeLine fourDayRecallTimeLine=new FourDayRecallTimeLine(patient,resumeDate,treatmentAdvice,daysToRetry);
  List<LocalDate> weekStartDates=fourDayRecallTimeLine.weekStartDates();
  if (weekStartDates.size() > 0) {
    if (allWeeklyAdherenceLogs.findLogsByWeekStartDate(patientId,treatmentAdviceDocId,weekStartDates.get(0)).size() == 0) {
      allWeeklyAdherenceLogs.add(WeeklyAdherenceLog.create(patientId,treatmentAdviceDocId,weekStartDates.get(0),doseTaken ? 0 : PatientPreferences.DAYS_TO_RECALL));
    }
    weekStartDates.remove(0);
  }
  for (  LocalDate date : weekStartDates) {
    allWeeklyAdherenceLogs.add(WeeklyAdherenceLog.create(patientId,treatmentAdviceDocId,date,doseTaken ? 0 : PatientPreferences.DAYS_TO_RECALL));
  }
}
Program: 84787
Project: 84787
Buggy source:
private boolean patientsBestCallTimeFallsWithinSuspensionPeriod(DateTime fromDate,DateTime toDate,Patient suspendedPatient,boolean isFirstDayOfSuspensionPeriod,boolean isLastDayOfSuspensionPeriod){
  return ((suspendedPatient.getPatientPreferences().getBestCallTime().toTime().getDateTime(toDate).compareTo(toDate) <= 0 && isLastDayOfSuspensionPeriod) || (suspendedPatient.getPatientPreferences().getBestCallTime().toTime().getDateTime(fromDate).compareTo(fromDate) >= 0 && isFirstDayOfSuspensionPeriod));
}

Fixed version (ground truth):
private boolean patientsBestCallTimeFallsWithinSuspensionPeriod(DateTime fromDate,DateTime toDate,Patient suspendedPatient,boolean isFirstDayOfSuspensionPeriod,boolean isLastDayOfSuspensionPeriod){
  return ((patientsBestCallTimeBeforeReactivationTime(toDate,suspendedPatient) && isLastDayOfSuspensionPeriod && !isFirstDayOfSuspensionPeriod) || (patientsBestCallTimeAfterSuspensionTime(fromDate,suspendedPatient) && isFirstDayOfSuspensionPeriod && !isLastDayOfSuspensionPeriod) || (patientsBestCallTimeBeforeReactivationTime(toDate,suspendedPatient) && isLastDayOfSuspensionPeriod && patientsBestCallTimeAfterSuspensionTime(fromDate,suspendedPatient)&& isFirstDayOfSuspensionPeriod));
}
Program: 84788
Project: 84788
Buggy source:
public boolean hasAdherenceFallingAlertBeenRaisedForCurrentWeek(String patientDocId){
  DateTime startDateForCurrentWeek=DateUtil.newDateTime(getStartDateForCurrentWeek(patientDocId),0,0,0);
  return patientAlertService.getFallingAdherenceAlerts(patientDocId,startDateForCurrentWeek,DateUtil.now()).size() > 0;
}

Fixed version (ground truth):
public boolean hasAdherenceFallingAlertBeenRaisedForCurrentWeek(String patientDocId){
  DateTime startDateForCurrentWeek=DateUtil.newDateTime(getMostRecentBestCallDay(patientDocId),0,0,0);
  return patientAlertService.getFallingAdherenceAlerts(patientDocId,startDateForCurrentWeek,DateUtil.now()).size() > 0;
}
Program: 84789
Project: 84789
Buggy source:
public boolean hasAdherenceInRedAlertBeenRaisedForCurrentWeek(String patientId){
  DateTime startDateForCurrentWeek=DateUtil.newDateTime(getStartDateForCurrentWeek(patientId),0,0,0);
  return patientAlertService.getAdherenceInRedAlerts(patientId,startDateForCurrentWeek,DateUtil.now()).size() > 0;
}

Fixed version (ground truth):
public boolean hasAdherenceInRedAlertBeenRaisedForCurrentWeek(String patientId){
  DateTime startDateForCurrentWeek=DateUtil.newDateTime(getMostRecentBestCallDay(patientId),0,0,0);
  return patientAlertService.getAdherenceInRedAlerts(patientId,startDateForCurrentWeek,DateUtil.now()).size() > 0;
}
Program: 84790
Project: 84790
Buggy source:
public boolean isAdherenceCapturedForAnyWeek(String patientDocId,String treatmentAdviceId,LocalDate weekStartDate){
  return 1 == allWeeklyAdherenceLogs.findLogsByWeekStartDate(patientDocId,treatmentAdviceId,weekStartDate).size();
}

Fixed version (ground truth):
public boolean isAdherenceCapturedForAnyWeek(String patientDocId,String treatmentAdviceId,LocalDate weekStartDate){
  return allWeeklyAdherenceLogs.findLogsByWeekStartDate(patientDocId,treatmentAdviceId,weekStartDate).size() > 0;
}
Program: 84791
Project: 84791
Buggy source:
@RequestMapping(method=RequestMethod.POST) public String changeRegimen(String existingTreatmentAdviceId,String discontinuationReason,TreatmentAdvice treatmentAdvice,Model uiModel,HttpServletRequest httpServletRequest){
  endCurrentRegimen(existingTreatmentAdviceId,discontinuationReason);
  uiModel.asMap().clear();
  Patient patient=allPatients.get(treatmentAdvice.getPatientId());
  allTreatmentAdvices.add(treatmentAdvice);
  final CallPreference callPreference=patient.getPatientPreferences().getCallPreference();
  if (callPreference.equals(CallPreference.DailyPillReminder)) {
    TreatmentAdvice oldTreatmentAdvice=allTreatmentAdvices.get(existingTreatmentAdviceId);
    pillReminderService.renew(pillRegimenRequestMapper.map(treatmentAdvice));
    schedulerService.unscheduleJobForAdherenceTrendFeedbackForDailyPillReminder(oldTreatmentAdvice);
    schedulerService.unscheduleJobForDeterminingAdherenceQualityInDailyPillReminder(patient);
    schedulerService.scheduleJobForAdherenceTrendFeedbackForDailyPillReminder(treatmentAdvice);
    schedulerService.scheduleJobForDeterminingAdherenceQualityInDailyPillReminder(patient,treatmentAdvice);
  }
 else   if (CallPreference.FourDayRecall.equals(callPreference)) {
    schedulerService.unscheduleFallingAdherenceAlertJobs(treatmentAdvice.getPatientId());
    schedulerService.scheduleFallingAdherenceAlertJobsForFourDayRecall(patient,treatmentAdvice);
  }
  return "String_Node_Str" + encodeUrlPathSegment(treatmentAdvice.getId(),httpServletRequest);
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.POST) public String changeRegimen(String existingTreatmentAdviceId,String discontinuationReason,TreatmentAdvice treatmentAdvice,Model uiModel,HttpServletRequest httpServletRequest){
  endCurrentRegimen(existingTreatmentAdviceId,discontinuationReason);
  uiModel.asMap().clear();
  Patient patient=allPatients.get(treatmentAdvice.getPatientId());
  allTreatmentAdvices.add(treatmentAdvice);
  final CallPreference callPreference=patient.getPatientPreferences().getCallPreference();
  if (callPreference.equals(CallPreference.DailyPillReminder)) {
    TreatmentAdvice oldTreatmentAdvice=allTreatmentAdvices.get(existingTreatmentAdviceId);
    pillReminderService.renew(pillRegimenRequestMapper.map(treatmentAdvice));
    schedulerService.unscheduleJobForAdherenceTrendFeedbackForDailyPillReminder(oldTreatmentAdvice);
    schedulerService.unscheduleJobForDeterminingAdherenceQualityInDailyPillReminder(patient);
    schedulerService.scheduleJobForAdherenceTrendFeedbackForDailyPillReminder(treatmentAdvice);
    schedulerService.scheduleJobForDeterminingAdherenceQualityInDailyPillReminder(patient,treatmentAdvice);
  }
 else   if (CallPreference.FourDayRecall.equals(callPreference)) {
    schedulerService.unScheduleFourDayRecallJobs(patient);
    schedulerService.scheduleJobsForFourDayRecall(patient,treatmentAdvice);
  }
  return "String_Node_Str" + encodeUrlPathSegment(treatmentAdvice.getId(),httpServletRequest);
}