Program: 23578
Project: 23578
Buggy source:
public org.hl7.fhir.dstu2.model.Encounter convertEncounter(org.hl7.fhir.dstu3.model.Encounter src) throws FHIRException {
  if (src == null)   return null;
  org.hl7.fhir.dstu2.model.Encounter tgt=new org.hl7.fhir.dstu2.model.Encounter();
  copyDomainResource(src,tgt);
  for (  org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())   tgt.addIdentifier(convertIdentifier(t));
  tgt.setStatus(convertEncounterState(src.getStatus()));
  for (  org.hl7.fhir.dstu3.model.Encounter.EncounterStatusHistoryComponent t : src.getStatusHistory())   tgt.addStatusHistory(convertEncounterStatusHistoryComponent(t));
  tgt.setClass_(convertEncounterClass(src.getClass_()));
  for (  org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())   tgt.addType(convertCodeableConcept(t));
  tgt.setPriority(convertCodeableConcept(src.getPriority()));
  tgt.setPatient(convertReference(src.getPatient()));
  for (  org.hl7.fhir.dstu3.model.Reference t : src.getEpisodeOfCare())   tgt.addEpisodeOfCare(convertReference(t));
  for (  org.hl7.fhir.dstu3.model.Reference t : src.getIncomingReferral())   tgt.addIncomingReferral(convertReference(t));
  for (  org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent t : src.getParticipant())   tgt.addParticipant(convertEncounterParticipantComponent(t));
  tgt.setAppointment(convertReference(src.getAppointment()));
  tgt.setPeriod(convertPeriod(src.getPeriod()));
  tgt.setLength(convertDuration(src.getLength()));
  for (  org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())   tgt.addReason(convertCodeableConcept(t));
  for (  org.hl7.fhir.dstu3.model.Reference t : src.getIndication())   tgt.addIndication(convertReference(t));
  tgt.setHospitalization(convertEncounterHospitalizationComponent(src.getHospitalization()));
  for (  org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent t : src.getLocation())   tgt.addLocation(convertEncounterLocationComponent(t));
  tgt.setServiceProvider(convertReference(src.getServiceProvider()));
  tgt.setPartOf(convertReference(src.getPartOf()));
  return tgt;
}

Fixed version (ground truth):
public org.hl7.fhir.dstu2.model.Encounter convertEncounter(org.hl7.fhir.dstu3.model.Encounter src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.Encounter tgt=new org.hl7.fhir.dstu2.model.Encounter();
  copyDomainResource(src,tgt);
  for (  org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())   tgt.addIdentifier(convertIdentifier(t));
  tgt.setStatus(convertEncounterState(src.getStatus()));
  for (  org.hl7.fhir.dstu3.model.Encounter.EncounterStatusHistoryComponent t : src.getStatusHistory())   tgt.addStatusHistory(convertEncounterStatusHistoryComponent(t));
  tgt.setClass_(convertEncounterClass(src.getClass_()));
  for (  org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())   tgt.addType(convertCodeableConcept(t));
  tgt.setPriority(convertCodeableConcept(src.getPriority()));
  tgt.setPatient(convertReference(src.getPatient()));
  for (  org.hl7.fhir.dstu3.model.Reference t : src.getEpisodeOfCare())   tgt.addEpisodeOfCare(convertReference(t));
  for (  org.hl7.fhir.dstu3.model.Reference t : src.getIncomingReferral())   tgt.addIncomingReferral(convertReference(t));
  for (  org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent t : src.getParticipant())   tgt.addParticipant(convertEncounterParticipantComponent(t));
  tgt.setAppointment(convertReference(src.getAppointment()));
  tgt.setPeriod(convertPeriod(src.getPeriod()));
  tgt.setLength(convertDuration(src.getLength()));
  for (  org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason())   tgt.addReason(convertCodeableConcept(t));
  for (  org.hl7.fhir.dstu3.model.Reference t : src.getIndication())   tgt.addIndication(convertReference(t));
  tgt.setHospitalization(convertEncounterHospitalizationComponent(src.getHospitalization()));
  for (  org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent t : src.getLocation())   tgt.addLocation(convertEncounterLocationComponent(t));
  tgt.setServiceProvider(convertReference(src.getServiceProvider()));
  tgt.setPartOf(convertReference(src.getPartOf()));
  return tgt;
}