@RequestMapping(method = RequestMethod.POST, value = "module/pharmacy/locationUsers")
  public synchronized void pageLoadd(HttpServletRequest request, HttpServletResponse response) {
    String locationName = request.getParameter("username"); // description
    String description = request.getParameter("locationname"); // description

    String edit = request.getParameter("locationeedit");
    String uuid = request.getParameter("locationuuid");
    String uuidvoid = request.getParameter("locationuuidvoid");
    String reason = request.getParameter("locationreason");

    userService = Context.getUserContext();
    if (edit != null) {

      if (edit.equalsIgnoreCase("false")) {
        // check for same entry before saving
        pharmacyLocationUsers = service.getPharmacyLocationUsers();
        size = pharmacyLocationUsers.size();
        for (int i = 0; i < size; i++) {

          found = getCheck(pharmacyLocationUsers, i, locationName);
          if (found) break;
        }

        pharmacyLocationUsers1 = new PharmacyLocationUsers();
        pharmacyLocationUsers1.setUserName(locationName);
        pharmacyLocationUsers1.setLocation(description);

        service.savePharmacyLocationUsers(pharmacyLocationUsers1);

      } else if (edit.equalsIgnoreCase("true")) {
        pharmacyLocationUsers1 = new PharmacyLocationUsers();

        pharmacyLocationUsers1 = service.getPharmacyLocationUsersByUuid(uuid);

        if (userService
            .getAuthenticatedUser()
            .getUserId()
            .equals(pharmacyLocationUsers1.getCreator().getUserId())) {

          // saving/updating a record
          pharmacyLocationUsers1.setUserName(locationName);
          pharmacyLocationUsers1.setLocation(description);

          service.savePharmacyLocationUsers(pharmacyLocationUsers1);
        }
      }

    } else if (uuidvoid != null) {

      pharmacyLocationUsers1 = new PharmacyLocationUsers();

      pharmacyLocationUsers1 = service.getPharmacyLocationUsersByUuid(uuidvoid);

      pharmacyLocationUsers1.setVoided(true);
      pharmacyLocationUsers1.setVoidReason(reason);

      service.savePharmacyLocationUsers(pharmacyLocationUsers1);
    }
  }
  @RequestMapping(method = RequestMethod.GET, value = "module/pharmacy/locationUsers")
  public synchronized void pageLoad(HttpServletRequest request, HttpServletResponse response) {

    userService = Context.getUserContext();
    String drop = request.getParameter("drop");
    String drug = request.getParameter("drug");
    String user = request.getParameter("user");
    String locations = request.getParameter("locations");
    int psize;

    service = Context.getService(PharmacyService.class);
    locationUsers = service.getPharmacyLocationUsers();
    size = locationUsers.size();
    jsonObject = new JSONObject();

    jsonArray = new JSONArray();

    try {

      if (drop != null) {
        if (drop.equalsIgnoreCase("drop")) {
          if (size != 0) {
            for (int i = 0; i < size; i++) {
              jsonArray.put("" + getDropDown(locationUsers, i));
            }

          } else jsonArray.put("" + null);

          response.getWriter().print(jsonArray);
        } else if (drop.equalsIgnoreCase("total")) {

          pharmacyInventory = service.getPharmacyInventory();
          sizeList = pharmacyInventory.size();

          if (size != 0) {
            for (int i = 0; i < sizeList; i++) {
              int val = getCheckSize(pharmacyInventory, i, drug);
              if (val == 0) {

              } else {
                jsonArray.put("" + val);
              }
              if (val != 0) break;
            }
          } else jsonArray.put("" + null);

          response.getWriter().print(jsonArray);
        }

      } else if (user != null) {

        userList =
            Context.getUserService().getUsers(user, Context.getUserService().getRoles(), true);

        psize = userList.size();

        jsonArray = new JSONArray();
        for (int i = 0; i < psize; i++) {

          jsonArray.put(userList.get(i).getUsername());
        }

        response.getWriter().print(jsonArray);
      } else if (locations != null) {

        pharmacyLocations = service.getPharmacyLocations();

        psize = pharmacyLocations.size();

        jsonArray = new JSONArray();
        for (int i = 0; i < psize; i++) {

          jsonArray.put(pharmacyLocations.get(i).getName());
        }

        response.getWriter().print(jsonArray);
      } else {

        if (size != 0) {
          for (int i = 0; i < size; i++) {

            jsonObject.accumulate("aaData", getArray(locationUsers, i));
          }
        }
        if (!jsonObject.has("aaData")) {

          datad2 = new JSONArray();
          datad2.put("None");
          datad2.put("None");
          datad2.put("None");

          datad2.put("None");
          datad2.put("None");
          datad2.put("None");
          jsonObject.accumulate("aaData", datad2);
        }
        jsonObject.accumulate("iTotalRecords", jsonObject.getJSONArray("aaData").length());
        jsonObject.accumulate("iTotalDisplayRecords", jsonObject.getJSONArray("aaData").length());
        jsonObject.accumulate("iDisplayStart", 0);
        jsonObject.accumulate("iDisplayLength", 10);

        response.getWriter().print(jsonObject);
      }
      response.flushBuffer();

    } catch (Exception e) {
      // TODO Auto-generated catch block
      log.error("Error generated", e);
    }
  }