Search in sources :

Example 1 with ProviderManagementService

use of org.openmrs.module.providermanagement.api.ProviderManagementService in project openmrs-module-coreapps by openmrs.

the class ProviderListPageController method get.

public void get(PageModel model, @SpringBean("providerManagementService") ProviderManagementService providerManagementService) throws PersonIsNotProviderException {
    Map<Provider, List<ProviderPersonRelationship>> providers = new HashMap<Provider, List<ProviderPersonRelationship>>();
    List<ProviderRole> providerRoleList = providerManagementService.getRestrictedProviderRoles(false);
    if (providerRoleList != null && providerRoleList.size() > 0) {
        List<Provider> providersByRoles = Context.getService(ProviderManagementService.class).getProvidersByRoles(providerRoleList);
        for (Provider providerByRole : providersByRoles) {
            List<ProviderPersonRelationship> supervisorsForProvider = ProviderManagementUtils.getSupervisors(providerByRole);
            if (supervisorsForProvider == null) {
                supervisorsForProvider = new ArrayList<ProviderPersonRelationship>();
            }
            providers.put(providerByRole, supervisorsForProvider);
        }
    }
    model.addAttribute("providersList", providers);
}
Also used : HashMap(java.util.HashMap) ProviderManagementService(org.openmrs.module.providermanagement.api.ProviderManagementService) ProviderRole(org.openmrs.module.providermanagement.ProviderRole) ArrayList(java.util.ArrayList) List(java.util.List) ProviderPersonRelationship(org.openmrs.module.providermanagement.relationship.ProviderPersonRelationship) Provider(org.openmrs.module.providermanagement.Provider)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Provider (org.openmrs.module.providermanagement.Provider)1 ProviderRole (org.openmrs.module.providermanagement.ProviderRole)1 ProviderManagementService (org.openmrs.module.providermanagement.api.ProviderManagementService)1 ProviderPersonRelationship (org.openmrs.module.providermanagement.relationship.ProviderPersonRelationship)1