public String execute() throws Exception {
    PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute(id);

    patientAttribute.setName(name);
    patientAttribute.setDescription(description);
    patientAttribute.setValueType(valueType);
    patientAttribute.setExpression(expression);

    mandatory = (mandatory == null) ? false : true;
    patientAttribute.setMandatory(mandatory);

    inherit = (inherit == null) ? false : true;
    patientAttribute.setInherit(inherit);

    HttpServletRequest request = ServletActionContext.getRequest();

    Collection<PatientAttributeOption> attributeOptions =
        patientAttributeOptionService.get(patientAttribute);

    if (attributeOptions != null && attributeOptions.size() > 0) {
      String value = null;
      for (PatientAttributeOption option : attributeOptions) {
        value = request.getParameter(PREFIX_ATTRIBUTE_OPTION + option.getId());
        if (StringUtils.isNotBlank(value)) {
          option.setName(value.trim());
          patientAttributeOptionService.updatePatientAttributeOption(option);
          patientAttributeValueService.updatePatientAttributeValues(option);
        }
      }
    }

    if (attrOptions != null) {
      PatientAttributeOption opt = null;
      for (String optionName : attrOptions) {
        opt = patientAttributeOptionService.get(patientAttribute, optionName);
        if (opt == null) {
          opt = new PatientAttributeOption();
          opt.setName(optionName);
          opt.setPatientAttribute(patientAttribute);
          patientAttribute.addAttributeOptions(opt);
          patientAttributeOptionService.addPatientAttributeOption(opt);
        }
      }
    }

    patientAttributeService.updatePatientAttribute(patientAttribute);

    return SUCCESS;
  }
  public String execute() throws Exception {
    // OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
    organisationUnit = organisationUnitService.getOrganisationUnit(ouIDTB);
    // ---------------------------------------------------------------------
    // Get all of patients into the selected organisation unit
    // ---------------------------------------------------------------------
    /*
        if ( listAll != null && listAll )
        {
            listAllPatient( organisationUnit );

            return SUCCESS;
        }
    */
    // ---------------------------------------------------------------------
    // Search patients by attributes
    // ---------------------------------------------------------------------

    // System.out.println( "searchingAttributeId= "  + searchingAttributeId + "---,searchText= " +
    // searchText );

    // System.out.println( "OrganisationUnit= "  + ouIDTB + "---,is Selected Org checked = " +
    // isSelectedOrg );

    raFolderName = reportService.getRAFolderName();

    programList = new ArrayList<ProgramDetail>();

    for (Integer attributeId : searchingAttributeId) {
      if (attributeId != null && attributeId != 0) {
        patientAttributes.add(patientAttributeService.getPatientAttribute(attributeId));
      }
    }

    if (isSelectedOrg) {
      searchPatientByNameAndOrgUnit(searchText, organisationUnit);
    } else {
      searchPatientByAttributes(searchingAttributeId, searchText);
      // searchPatientByNameAndOrgUnit( searchText , organisationUnit );
    }

    getProgramDetailList();

    return SUCCESS;
  }