Source:
<code>public SimpleObject update(String uuid, SimpleObject postBody, RequestContext context) { String manualEntryEnabled = postBody.get("manualEntryEnabled").toString(); String automaticGenerationEnabled = postBody.get("automaticGenerationEnabled").toString(); String sourceUuid = postBody.get("source").toString(); String locationUuid = postBody.get("location").toString(); <START> <END> IdentifierSource identifierSource = Context.getService(IdentifierSourceService.class) .getIdentifierSourceByUuid(sourceUuid); PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(uuid); Location location = Context.getLocationService().getLocationByUuid(locationUuid); AutoGenerationOption autoGenerationOption = Context.getService(IdentifierSourceService.class) .getAutoGenerationOption(patientIdentifierType); autoGenerationOption.setManualEntryEnabled(Boolean.parseBoolean(manualEntryEnabled)); autoGenerationOption.setAutomaticGenerationEnabled(Boolean.parseBoolean(automaticGenerationEnabled)); autoGenerationOption.setSource(identifierSource); autoGenerationOption.setLocation(location); return (SimpleObject) ConversionUtil.convertToRepresentation(save(autoGenerationOption), Representation.REF); }</code><technical_language>Validate user inputs proceeding</technical_language>

Target:
public SimpleObject update(String uuid, SimpleObject postBody, RequestContext context) throws ResponseException { String manualEntryEnabled = ((postBody.get("manualEntryEnabled") != null) && !(postBody.get("manualEntryEnabled").equals(""))) ? postBody.get("manualEntryEnabled").toString() : null; String automaticGenerationEnabled = ((postBody.get("automaticGenerationEnabled") != null) && !(postBody.get("automaticGenerationEnabled").equals(""))) ? postBody.get("automaticGenerationEnabled").toString() : null; String sourceUuid = ((postBody.get("source") != null) && !(postBody.get("source").equals(""))) ? postBody.get("source").toString() : null; String locationUuid = ((postBody.get("location") != null) && !(postBody.get("location").equals(""))) ? postBody.get("location").toString() : null; AutoGenerationOption autoGenerationOption = Context.getService(IdentifierSourceService.class) .getAutoGenerationOption(Integer.parseInt(uuid)); if (manualEntryEnabled != null) { autoGenerationOption.setManualEntryEnabled(Boolean.parseBoolean(manualEntryEnabled)); } if (automaticGenerationEnabled != null) { autoGenerationOption.setAutomaticGenerationEnabled(Boolean.parseBoolean(automaticGenerationEnabled)); } if (sourceUuid != null) { IdentifierSource identifierSource = identifierSourceService.getIdentifierSourceByUuid(sourceUuid); autoGenerationOption.setSource(identifierSource); } if (locationUuid != null) { Location location = Context.getLocationService().getLocationByUuid(locationUuid); autoGenerationOption.setLocation(location); } if (locationUuid == null && sourceUuid == null && automaticGenerationEnabled == null && manualEntryEnabled == null) { throw new ResourceDoesNotSupportOperationException( "updating an autoGenerationOption with missing parameters is not supported"); } return (SimpleObject) ConversionUtil.convertToRepresentation(save(autoGenerationOption), Representation.REF); }