OpenMRSUserService

public interface OpenMRSUserService

Interface for handling users on the OpenMRS server.

Fields

PASSWORD_KEY

String PASSWORD_KEY

Key to obtain password from createUser(String,User) and updateUser(String,User)

USER_KEY

String USER_KEY

Key to obtain User from createUser(String,User) and updateUser(String,User)

Methods

changeCurrentUserPassword

void changeCurrentUserPassword(String configName, String currentPassword, String newPassword)

Changes the password of the current user. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • currentPassword – the current password
  • newPassword – the new password

createUser

User createUser(String configName, User user)

Creates the given user on the OpenMRS server. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • user – the user to be created
Throws:
Returns:

the created user

deleteUser

void deleteUser(String configName, String uuid)

Deletes the user with the given uuid. If the provider with the given uuid doesn’t exist an error will be logged. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • uuid – the UUID of the user
Throws:

getAllUsers

List<User> getAllUsers(String configName)

Returns a list of all users on the OpenMRS server. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
Returns:

the list of all users

getUserByUserName

User getUserByUserName(String configName, String userName)

Returns the user with the given userName. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • userName – the username of the user
Returns:

the user with the given username, null if the user doesn’t exist

getUserByUuid

User getUserByUuid(String configName, String uuid)

Return the user with the given uuid. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • uuid – the UUID of the user
Returns:

the user with the given UUID, null if the user doesn’t exist

setNewPasswordForUser

String setNewPasswordForUser(String configName, String username)

Resets the password of the user with the given username. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • username – the name of the user
Returns:

the new password, null if the user doesn’t exist

updateUser

User updateUser(String configName, User user)

Updates the user with the information stored in the given user. Configuration with the given configName will be used while performing this action.

Parameters:
  • configName – the name of the configuration
  • user – the user to be used as an update source
Returns:

the update user, null if the user doesn’t exist