Source:
<code>public SimpleObject create(SimpleObject postBody, RequestContext context) throws ResponseException { Object manualEntryEnabled = (postBody.get("manualEntryEnabled")); Object automaticallyEnabled = postBody.get("automaticGenerationEnabled"); Object sourceUuid = postBody.get("source"); Object locationUuid = postBody.get("location"); Object identifierTypeUuid = postBody.get("identifierType"); ArrayList<String> errors = new ArrayList<String>(); if (sourceUuid == null || StringUtils.isBlank(sourceUuid.toString())) { errors.add("source"); } if (identifierTypeUuid == null || StringUtils.isBlank(identifierTypeUuid.toString())) { errors.add("identifierType"); } if (errors.size() > 0) { throw new ValidationException("The values of the following inputs are missing: " + errors.toString()); } IdentifierSource identifierSource = identifierSourceService.getIdentifierSourceByUuid(sourceUuid.toString()); if (identifierSource == null) { errors.add("source"); } PatientIdentifierType patientIdentifierType = Context.getPatientService() .getPatientIdentifierTypeByUuid(identifierTypeUuid.toString()); if (patientIdentifierType == null) { errors.add("IdentifierType"); } <START> if (errors.size() > 0) { <END> throw new ValidationException("The values of the following inputs are invalid: " + errors.toString()); } Location location = null; if (locationUuid != null && StringUtils.isNotBlank(identifierTypeUuid.toString())) { location = Context.getLocationService().getLocationByUuid(locationUuid.toString()); } if (location == null) { location = Context.getLocationService() .getLocationByUuid(Context.getLocationService().getDefaultLocation().getUuid()); } AutoGenerationOption autoGenerationOption = new AutoGenerationOption(); autoGenerationOption.setSource(identifierSource); autoGenerationOption.setIdentifierType(patientIdentifierType); autoGenerationOption.setManualEntryEnabled(this.parseBoolean(manualEntryEnabled.toString())); autoGenerationOption.setAutomaticGenerationEnabled(this.parseBoolean(automaticallyEnabled.toString())); autoGenerationOption.setLocation(location); return (SimpleObject) ConversionUtil.convertToRepresentation(save(autoGenerationOption), Representation.FULL); }</code><technical_language>Is necessary repeat this</technical_language>

Target:
public SimpleObject create(SimpleObject postBody, RequestContext context) throws ResponseException { Object manualEntryEnabled = postBody.get("manualEntryEnabled"); Object automaticallyEnabled = postBody.get("automaticGenerationEnabled"); Object sourceUuid = postBody.get("source"); Object locationUuid = postBody.get("location"); Object identifierTypeUuid = postBody.get("identifierType"); ArrayList<String> errors = new ArrayList<String>(); IdentifierSource identifierSource = null; PatientIdentifierType patientIdentifierType = null; if (sourceUuid == null || StringUtils.isBlank(sourceUuid.toString())) { errors.add("source"); } else { identifierSource = Context.getService(IdentifierSourceService.class) .getIdentifierSourceByUuid(sourceUuid.toString()); if (identifierSource == null) { errors.add("source"); } } if (identifierTypeUuid == null || StringUtils.isBlank(identifierTypeUuid.toString())) { errors.add("identifierType"); } else { patientIdentifierType = Context.getPatientService() .getPatientIdentifierTypeByUuid(identifierTypeUuid.toString()); if (patientIdentifierType == null) { errors.add("identifierType"); } } if (errors.size() > 0) { throw new ValidationException( "The values of the following inputs are missing or invalid : " + errors.toString()); } Location location = null; if (locationUuid != null && StringUtils.isNotBlank(locationUuid.toString())) { location = Context.getLocationService().getLocationByUuid(locationUuid.toString()); } AutoGenerationOption autoGenerationOption = new AutoGenerationOption(); autoGenerationOption.setSource(identifierSource); autoGenerationOption.setIdentifierType(patientIdentifierType); autoGenerationOption.setManualEntryEnabled(this.parseBoolean(manualEntryEnabled)); autoGenerationOption.setAutomaticGenerationEnabled(this.parseBoolean(automaticallyEnabled)); autoGenerationOption.setLocation(location); return (SimpleObject) ConversionUtil.convertToRepresentation(save(autoGenerationOption), Representation.FULL); }