Program: 144230
Project: 144230
Buggy source:
public static Section buildPregnancyHistorySection(Patient patient){
  List<Concept> socialHistoryConceptsList=new ArrayList<Concept>();
  Map<String,String> mappings=new HashMap<String,String>();
  Section section=CDAFactory.eINSTANCE.createSection();
  PregnancyHistorySection ccs=new PregnancyHistorySection();
  section.getTemplateIds().add(CDAHelper.buildTemplateID(ccs.getTemplateid(),null,null));
  section.setCode(CDAHelper.buildCodeCE(ccs.getCode(),ccs.getCodeSystem(),ccs.getSectionName(),ccs.getCodeSystemName()));
  section.setTitle(CDAHelper.buildTitle(ccs.getSectionDescription()));
  StrucDocText text=CDAFactory.eINSTANCE.createStrucDocText();
  StringBuilder builder=new StringBuilder();
  String delimeter="String_Node_Str";
  builder.append(delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  ConceptService service=Context.getConceptService();
  for (  Map.Entry<String,String> entry : mappings.entrySet()) {
    Concept concepts=service.getConceptByMapping(entry.getKey(),entry.getValue());
    if (concepts == null) {
      throw new APIException(Context.getMessageSourceService().getMessage("String_Node_Str",new Object[]{entry.getKey(),entry.getValue()},null));
    }
 else {
      socialHistoryConceptsList.add(concepts);
    }
  }
  List<Obs> obsList=new ArrayList<Obs>();
  for (  Concept concept : socialHistoryConceptsList) {
    obsList.addAll(Context.getObsService().getObservationsByPersonAndConcept(patient,concept));
    if (obsList.isEmpty()) {
      throw new APIException(Context.getMessageSourceService().getMessage("String_Node_Str",new Object[]{concept.getConceptId(),concept.getName()},null));
    }
  }
  for (  Obs obs : obsList) {
    builder.append("String_Node_Str" + delimeter);
    builder.append("String_Node_Str" + obs.getId() + "String_Node_Str"+ obs.getConcept().getName()+ "String_Node_Str"+ delimeter);
    builder.append("String_Node_Str");
    int type=obs.getConcept().getDatatype().getId();
    String value=CDAHelper.getDatatypesValue(type,obs);
    builder.append(value + "String_Node_Str" + delimeter);
    builder.append("String_Node_Str" + CDAHelper.getDateFormat().format(obs.getObsDatetime()) + "String_Node_Str"+ delimeter);
    builder.append("String_Node_Str" + delimeter);
    Entry e=CDAFactory.eINSTANCE.createEntry();
    e.setTypeCode(x_ActRelationshipEntry.DRIV);
    Organizer organizer=CDAFactory.eINSTANCE.createOrganizer();
    organizer.setClassCode(x_ActClassDocumentEntryOrganizer.CLUSTER);
    organizer.setMoodCode(ActMood.EVN);
    organizer.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    organizer.getIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    organizer.setCode(CDAHelper.buildCodeCD("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
    CS cs=DatatypesFactory.eINSTANCE.createCS();
    cs.setCode("String_Node_Str");
    organizer.setStatusCode(cs);
    IVL_TS effectiveTime=DatatypesFactory.eINSTANCE.createIVL_TS();
    Date d=new Date();
    SimpleDateFormat s=new SimpleDateFormat("String_Node_Str");
    String creationDate=s.format(d);
    effectiveTime.setValue(creationDate);
    organizer.setEffectiveTime(effectiveTime);
    Component4 component=CDAFactory.eINSTANCE.createComponent4();
    Observation observation=CDAFactory.eINSTANCE.createObservation();
    observation.setClassCode(ActClassObservation.OBS);
    observation.setMoodCode(x_ActMoodDocumentObservation.EVN);
    observation.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.getIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.setCode(CDAHelper.buildCodeCE("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
    observation.setText(CDAHelper.buildEDText("String_Node_Str" + obs.getId()));
    CS statusCode=DatatypesFactory.eINSTANCE.createCS();
    statusCode.setCode("String_Node_Str");
    observation.setStatusCode(statusCode);
    observation.setEffectiveTime(effectiveTime);
    ST value1=CDAHelper.buildTitle(value);
    observation.getValues().add(value1);
    component.setObservation(observation);
    organizer.getComponents().add(component);
    e.setOrganizer(organizer);
    section.getEntries().add(e);
  }
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  text.addText(builder.toString());
  section.setText(text);
  return section;
}

Fixed version (ground truth):
public static Section buildPregnancyHistorySection(Patient patient){
  List<Concept> ConceptsList=new ArrayList<Concept>();
  Map<String,String> mappings=new HashMap<String,String>();
  Section section=CDAFactory.eINSTANCE.createSection();
  PregnancyHistorySection ccs=new PregnancyHistorySection();
  section.getTemplateIds().add(CDAHelper.buildTemplateID(ccs.getTemplateid(),null,null));
  section.setCode(CDAHelper.buildCodeCE(ccs.getCode(),ccs.getCodeSystem(),ccs.getSectionName(),ccs.getCodeSystemName()));
  section.setTitle(CDAHelper.buildTitle(ccs.getSectionDescription()));
  StrucDocText text=CDAFactory.eINSTANCE.createStrucDocText();
  StringBuilder builder=new StringBuilder();
  String delimeter="String_Node_Str";
  builder.append(delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  mappings.put("String_Node_Str","String_Node_Str");
  ConceptService service=Context.getConceptService();
  for (  Map.Entry<String,String> entry : mappings.entrySet()) {
    Concept concepts=service.getConceptByMapping(entry.getKey(),entry.getValue());
    if (concepts == null) {
      throw new APIException(Context.getMessageSourceService().getMessage("String_Node_Str",new Object[]{entry.getKey(),entry.getValue()},null));
    }
 else {
      ConceptsList.add(concepts);
    }
  }
  List<Obs> obsList=new ArrayList<Obs>();
  for (  Concept concept : ConceptsList) {
    obsList.addAll(Context.getObsService().getObservationsByPersonAndConcept(patient,concept));
    if (obsList.isEmpty()) {
      throw new APIException(Context.getMessageSourceService().getMessage("String_Node_Str",new Object[]{concept.getConceptId(),concept.getName()},null));
    }
  }
  for (  Obs obs : obsList) {
    builder.append("String_Node_Str" + delimeter);
    builder.append("String_Node_Str" + obs.getId() + ccs.getCode()+ "String_Node_Str"+ obs.getConcept().getName()+ "String_Node_Str"+ delimeter);
    builder.append("String_Node_Str");
    int type=obs.getConcept().getDatatype().getId();
    String value=CDAHelper.getDatatypesValue(type,obs);
    builder.append(value + "String_Node_Str" + delimeter);
    builder.append("String_Node_Str" + CDAHelper.getDateFormat().format(obs.getObsDatetime()) + "String_Node_Str"+ delimeter);
    builder.append("String_Node_Str" + delimeter);
    Entry e=CDAFactory.eINSTANCE.createEntry();
    e.setTypeCode(x_ActRelationshipEntry.DRIV);
    Organizer organizer=CDAFactory.eINSTANCE.createOrganizer();
    organizer.setClassCode(x_ActClassDocumentEntryOrganizer.CLUSTER);
    organizer.setMoodCode(ActMood.EVN);
    organizer.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    organizer.getIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    organizer.setCode(CDAHelper.buildCodeCD("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
    organizer.setStatusCode(CDAHelper.getStatusCode());
    organizer.setEffectiveTime(CDAHelper.buildDateTime(new Date()));
    Component4 component=CDAFactory.eINSTANCE.createComponent4();
    Observation observation=CDAFactory.eINSTANCE.createObservation();
    observation.setClassCode(ActClassObservation.OBS);
    observation.setMoodCode(x_ActMoodDocumentObservation.EVN);
    observation.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.getIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.setCode(CDAHelper.buildCodeCE("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
    observation.setText(CDAHelper.buildEDText("String_Node_Str" + obs.getId() + ccs.getCode()));
    observation.setStatusCode(CDAHelper.getStatusCode());
    observation.setEffectiveTime(CDAHelper.buildDateTime(new Date()));
    ST value1=CDAHelper.buildTitle(value);
    observation.getValues().add(value1);
    component.setObservation(observation);
    organizer.getComponents().add(component);
    e.setOrganizer(organizer);
    section.getEntries().add(e);
  }
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  text.addText(builder.toString());
  section.setText(text);
  return section;
}