Program: 144229
Project: 144229
Buggy source:
public static Section buildCodedVitalSignsSection(Patient patient){
  List<Concept> ConceptsList=new ArrayList<Concept>();
  Map<String,String> mappings=new HashMap<String,String>();
  String units="String_Node_Str";
  Section section=CDAFactory.eINSTANCE.createSection();
  VitalSignsSection vss=new VitalSignsSection();
  CodedVitalSignsSection ccs=new CodedVitalSignsSection();
  section.getTemplateIds().add(CDAHelper.buildTemplateID(vss.getParentTemplateId(),null,null));
  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);
  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) {
    if (obs.getConcept().isNumeric()) {
      ConceptNumeric conceptNumeric=Context.getConceptService().getConceptNumeric(obs.getConcept().getId());
      units=conceptNumeric.getUnits();
    }
    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.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    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.getIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.setCode(CDAHelper.buildCodeCE("String_Node_Str","String_Node_Str",null,"String_Node_Str"));
    observation.setText(CDAHelper.buildEDText("String_Node_Str" + obs.getId()));
    observation.setStatusCode(CDAHelper.getStatusCode());
    observation.setEffectiveTime(CDAHelper.buildDateTime(new Date()));
    PQ value1=DatatypesFactory.eINSTANCE.createPQ();
    BigDecimal number=new BigDecimal(value);
    value1.setValue(number);
    value1.setUnit(units);
    observation.getValues().add(value1);
    component.setObservation(observation);
    organizer.getComponents().add(component);
    organizer.setStatusCode(CDAHelper.getStatusCode());
    e.setOrganizer(organizer);
    section.getEntries().add(e);
    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 buildCodedVitalSignsSection(Patient patient){
  List<Concept> ConceptsList=new ArrayList<Concept>();
  Map<String,String> mappings=new HashMap<String,String>();
  String units="String_Node_Str";
  Section section=CDAFactory.eINSTANCE.createSection();
  VitalSignsSection vss=new VitalSignsSection();
  CodedVitalSignsSection ccs=new CodedVitalSignsSection();
  section.getTemplateIds().add(CDAHelper.buildTemplateID(vss.getParentTemplateId(),null,null));
  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);
  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) {
    if (obs.getConcept().isNumeric()) {
      ConceptNumeric conceptNumeric=Context.getConceptService().getConceptNumeric(obs.getConcept().getId());
      units=conceptNumeric.getUnits();
      units=units.replaceAll("String_Node_Str","String_Node_Str");
      System.out.println(units);
    }
    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.getTemplateIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    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.getIds().add(CDAHelper.buildTemplateID("String_Node_Str",null,null));
    observation.setCode(CDAHelper.buildCodeCE("String_Node_Str","String_Node_Str",null,"String_Node_Str"));
    observation.setText(CDAHelper.buildEDText("String_Node_Str" + obs.getId()));
    observation.setStatusCode(CDAHelper.getStatusCode());
    observation.setEffectiveTime(CDAHelper.buildDateTime(new Date()));
    PQ value1=DatatypesFactory.eINSTANCE.createPQ();
    BigDecimal number=new BigDecimal(value);
    value1.setValue(number);
    value1.setUnit(units);
    observation.getValues().add(value1);
    component.setObservation(observation);
    organizer.getComponents().add(component);
    organizer.setStatusCode(CDAHelper.getStatusCode());
    e.setOrganizer(organizer);
    section.getEntries().add(e);
    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;
}