Program: 144228
Project: 144228
Buggy source:
public static Section buildSocialHistorySection(Patient p){
  List<Concept> socialHistoryConceptsList=new ArrayList<Concept>();
  Section section=CDAFactory.eINSTANCE.createSection();
  SocialHistorySection ccs=new SocialHistorySection();
  section.getTemplateIds().add(CDAHelper.buildTemplateID(ccs.getParentTemplateId(),null,null));
  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);
  ConceptService service=Context.getConceptService();
  SimpleDateFormat s=new SimpleDateFormat("String_Node_Str");
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  System.out.println(socialHistoryConceptsList);
  List<Obs> obsList=new ArrayList<Obs>();
  for (  Concept concept : socialHistoryConceptsList) {
    obsList.addAll(Context.getObsService().getObservationsByPersonAndConcept(p,concept));
  }
  for (  Obs obs : obsList) {
    System.out.println(obs);
    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=getDatatypesValue(type,obs);
    builder.append(value + "String_Node_Str" + delimeter);
    builder.append("String_Node_Str" + s.format(obs.getObsDatetime()) + "String_Node_Str"+ delimeter);
    builder.append("String_Node_Str" + delimeter);
    Entry entry=CDAFactory.eINSTANCE.createEntry();
    entry.setTypeCode(x_ActRelationshipEntry.DRIV);
    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.getIds().add(CDAHelper.buildID(obs.getUuid(),null));
    CD ce=DatatypesFactory.eINSTANCE.createCD();
    ce.setCode(obs.getConcept().toString());
    ce.setCodeSystem("String_Node_Str");
    ce.setDisplayName(obs.getConcept().getName().toString());
    ce.setOriginalText(CDAHelper.buildEDText("String_Node_Str" + obs.getId()));
    observation.setCode(ce);
    CS statusCode=DatatypesFactory.eINSTANCE.createCS();
    statusCode.setCode("String_Node_Str");
    observation.setStatusCode(statusCode);
    observation.setEffectiveTime(CDAHelper.buildEffectiveTimeinIVL(obs.getObsDatetime(),null));
    ST value1=CDAHelper.buildTitle(value);
    observation.getValues().add(value1);
    entry.setObservation(observation);
    section.getEntries().add(entry);
  }
  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 buildSocialHistorySection(Patient p){
  List<Concept> socialHistoryConceptsList=new ArrayList<Concept>();
  Section section=CDAFactory.eINSTANCE.createSection();
  SocialHistorySection ccs=new SocialHistorySection();
  section.getTemplateIds().add(CDAHelper.buildTemplateID(ccs.getParentTemplateId(),null,null));
  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);
  ConceptService service=Context.getConceptService();
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  socialHistoryConceptsList.add(service.getConceptByMapping("String_Node_Str","String_Node_Str"));
  System.out.println(socialHistoryConceptsList);
  List<Obs> obsList=new ArrayList<Obs>();
  for (  Concept concept : socialHistoryConceptsList) {
    obsList.addAll(Context.getObsService().getObservationsByPersonAndConcept(p,concept));
  }
  for (  Obs obs : obsList) {
    System.out.println(obs);
    System.out.println(obs.getObsDatetime());
    System.out.println(CDAHelper.getDateFormat().format(obs.getObsDatetime()));
    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 entry=CDAFactory.eINSTANCE.createEntry();
    entry.setTypeCode(x_ActRelationshipEntry.DRIV);
    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.getIds().add(CDAHelper.buildID(obs.getUuid(),null));
    CD ce=DatatypesFactory.eINSTANCE.createCD();
    ce.setCode(obs.getConcept().toString());
    ce.setCodeSystem("String_Node_Str");
    ce.setDisplayName(obs.getConcept().getName().toString());
    ce.setOriginalText(CDAHelper.buildEDText("String_Node_Str" + obs.getId()));
    observation.setCode(ce);
    CS statusCode=DatatypesFactory.eINSTANCE.createCS();
    statusCode.setCode("String_Node_Str");
    observation.setStatusCode(statusCode);
    observation.setEffectiveTime(CDAHelper.buildEffectiveTimeinIVL(obs.getObsDatetime(),null));
    ST value1=CDAHelper.buildTitle(value);
    observation.getValues().add(value1);
    entry.setObservation(observation);
    section.getEntries().add(entry);
  }
  builder.append("String_Node_Str" + delimeter);
  builder.append("String_Node_Str" + delimeter);
  text.addText(builder.toString());
  section.setText(text);
  return section;
}