Source:
<code>public Encounter createFHIREncounter(Encounter encounter) { List<String> errors = new ArrayList<String>(); org.openmrs.Encounter encounterToCreate = null; ResourceReferenceDt encounterref = encounter.getPartOf(); Visit visit = null; if (encounterref != null && !encounterref.isEmpty()) { encounterToCreate = FHIREncounterUtil.generateOMRSEncounter(encounter, errors); IdDt ref = encounterref.getReference(); <START> String encounterrefuuid = ref.getIdPart(); <END> visit = Context.getVisitService().getVisitByUuid(encounterrefuuid); if (visit == null) { errors.add("No Encounters found for :" + encounterrefuuid); } else { encounterToCreate.setVisit(visit); } } else { org.openmrs.Patient patient = null; if (encounter.getPatient() != null) { ResourceReferenceDt patientref = encounter.getPatient(); IdDt id = patientref.getReference(); String patientUuid = id.getIdPart(); patient = Context.getPatientService().getPatientByUuid(patientUuid); if (patient == null) { errors.add("There is no patient for the given uuid " + patientUuid); } } List<Visit> activeVisits = Context.getVisitService().getActiveVisitsByPatient(patient); for (Visit activeVisit : activeVisits) { activeVisit.setStopDatetime(new Date()); } visit = FHIREncounterUtil.generateOMRSVisit(encounter, errors); } if (!errors.isEmpty()) { StringBuilder errorMessage = new StringBuilder("The request cannot be processed due to the following issues \n"); for (int i = 0; i < errors.size(); i++) { errorMessage.append((i + 1) + " : " + errors.get(i) + "\n"); } throw new UnprocessableEntityException(errorMessage.toString()); } if (encounterref != null && !encounterref.isEmpty()) { encounterToCreate = Context.getEncounterService().saveEncounter(encounterToCreate); return FHIREncounterUtil.generateEncounter(encounterToCreate); } else { visit = Context.getVisitService().saveVisit(visit); return OMRSFHIRVisitUtil.generateEncounter(visit); } }</code><technical_language>camel case encounterRefuuid</technical_language>

Target:
public Encounter createFHIREncounter(Encounter encounter) { List<String> errors = new ArrayList<String>(); org.openmrs.Encounter encounterToCreate = null; ResourceReferenceDt encounterRef = encounter.getPartOf(); Visit visit = null; if (encounterRef != null && !encounterRef.isEmpty()) { encounterToCreate = FHIREncounterUtil.generateOMRSEncounter(encounter, errors); IdDt ref = encounterRef.getReference(); String encounterRefUuid = ref.getIdPart(); visit = Context.getVisitService().getVisitByUuid(encounterRefUuid); if (visit == null) { errors.add("No Encounters found for :" + encounterRefUuid); } else { encounterToCreate.setVisit(visit); } } else { org.openmrs.Patient patient = null; if (encounter.getPatient() != null) { ResourceReferenceDt patientRef = encounter.getPatient(); IdDt id = patientRef.getReference(); String patientUuid = id.getIdPart(); patient = Context.getPatientService().getPatientByUuid(patientUuid); if (patient == null) { errors.add("There is no patient for the given uuid " + patientUuid); } } List<Visit> activeVisits = Context.getVisitService().getActiveVisitsByPatient(patient); for (Visit activeVisit : activeVisits) { activeVisit.setStopDatetime(new Date()); } visit = FHIREncounterUtil.generateOMRSVisit(encounter, errors); } if (!errors.isEmpty()) { StringBuilder errorMessage = new StringBuilder("The request cannot be processed due to the following issues \n"); for (int i = 0; i < errors.size(); i++) { errorMessage.append((i + 1) + " : " + errors.get(i) + "\n"); } throw new UnprocessableEntityException(errorMessage.toString()); } if (encounterRef != null && !encounterRef.isEmpty()) { encounterToCreate = Context.getEncounterService().saveEncounter(encounterToCreate); return FHIREncounterUtil.generateEncounter(encounterToCreate); } else { visit = Context.getVisitService().saveVisit(visit); return OMRSFHIRVisitUtil.generateEncounter(visit); } }