@Post("xml")
  public Representation testDoctor(Representation entity) {

    DomRepresentation representation = null;
    try {
      DomRepresentation input = new DomRepresentation(entity);
      // input
      Document doc = input.getDocument();
      Element rootEl = doc.getDocumentElement();
      String username = XMLUtils.getTextValue(rootEl, "username");
      String firstName = XMLUtils.getTextValue(rootEl, "firstname");
      String lastName = XMLUtils.getTextValue(rootEl, "lastname");

      // output
      representation = new DomRepresentation(MediaType.TEXT_XML);

      String res = "OK " + username;

      Map<String, String> map = new HashMap<String, String>();
      map.put("result", res);
      Document d = representation.getDocument();
      d = XMLUtils.createXMLResult("doctorTestOutput", map, d);

    } catch (IOException e) {
      representation = XMLUtils.createXMLError("login error", "" + e.getMessage());
    }

    // Returns the XML representation of this document.
    return representation;
  }
  @Post("xml")
  public Representation acceptItem(Representation entity) {

    DomRepresentation result = null;
    Document d = null;
    try {

      DomRepresentation input = new DomRepresentation(entity);
      Document doc = input.getDocument();
      // handle input document
      Element rootEl = doc.getDocumentElement();
      String usernameDoctor = XMLUtils.getTextValue(rootEl, "username");
      // output
      result = new DomRepresentation(MediaType.TEXT_XML);
      d = result.getDocument();

      try {
        ObjectifyService.register(Patient.class);
        ObjectifyService.register(Relative.class);
      } catch (Exception e) {
      }

      Key<Relative> doctor = new Key<Relative>(Relative.class, usernameDoctor);

      Objectify ofy = ObjectifyService.begin();

      List<Patient> listRU = ofy.query(Patient.class).filter("doctor", doctor).list();

      Element root = d.createElement("getUsers");
      d.appendChild(root);

      Element eltName4 = d.createElement("getUsersList");

      for (Patient us : listRU) {

        Element user = d.createElement("user");

        user.setAttribute("firstname", "" + us.getFirstName());
        user.setAttribute("lastname", "" + us.getLastName());
        user.setAttribute("username", "" + us.getUsername());
        user.setAttribute("password", "" + us.getPassword());
        user.appendChild(d.createTextNode(us.getUsername()));
        eltName4.appendChild(user);
      }
      root.appendChild(eltName4);

      d.normalizeDocument();

    } catch (Exception e) {
      result = XMLUtils.createXMLError("get doctors list error", "" + e.getMessage());
    }

    return result;
  }
  @Post("xml")
  public Representation acceptItem(Representation entity) {

    DomRepresentation representation = null;
    try {
      DomRepresentation input = new DomRepresentation(entity);
      // input
      Document doc = input.getDocument();
      Element rootEl = doc.getDocumentElement();
      String username = XMLUtils.getTextValue(rootEl, "username");

      // output
      representation = new DomRepresentation(MediaType.TEXT_XML);

      // Generate a DOM document representing the list of
      // items.

      String res = "";
      try {
        ObjectifyService.register(Patient.class);
      } catch (Exception e) {
      }

      Objectify ofy = ObjectifyService.begin();
      Patient us = ofy.query(Patient.class).filter("username", username).get();
      if (us == null) {
        res = "user not found.";
      } else {

        ofy.delete(us);
        res = "OK, " + us.getUsername() + " deleted.";
      }
      getLogger().info("res: " + res);
      Map<String, String> map = new HashMap<String, String>();
      map.put("result", res);
      Document d = representation.getDocument();
      d = XMLUtils.createXMLResult("rehabDeleteUserOutput", map, d);

    } catch (IOException e) {
      representation = XMLUtils.createXMLError("user delete error", "" + e.getMessage());
    }

    // Returns the XML representation of this document.
    return representation;
  }