/** @see PropertyEditorSupport#getAsText() */
 public String getAsText() {
   AutoGenerationOption option = (AutoGenerationOption) getValue();
   if (option != null) {
     return option.getId().toString();
   }
   return null;
 }
  /** Edit a new or existing AutoGeneration Option */
  @RequestMapping("/module/idgen/editAutoGenerationOption")
  public void editAutoGenerationOption(
      ModelMap model,
      HttpServletRequest request,
      @RequestParam(required = false, value = "autoGenerationOption")
          AutoGenerationOption option, // expects to get either an option or an identifier type
      @RequestParam(required = false, value = "identifierType") PatientIdentifierType type) {

    if (Context.isAuthenticated()) {
      Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());

      IdentifierSourceService iss = Context.getService(IdentifierSourceService.class);
      LocationService locationService = Context.getLocationService();

      if (option == null) {
        option = new AutoGenerationOption(type);
      }

      model.addAttribute("option", option);
      model.addAttribute(
          "availableSources", iss.getIdentifierSourcesByType(true).get(option.getIdentifierType()));
      model.addAttribute("availableLocations", locationService.getAllLocations());
    }
  }