Search in sources :

Example 1 with ProviderRole

use of org.openmrs.module.providermanagement.ProviderRole in project openmrs-module-pihcore by PIH.

the class PihConstructors method providerRole.

public static ProviderRole providerRole(String name, Set<ProviderRole> superviseeProviderRoles, Set<RelationshipType> relationshipTypes, Set<ProviderAttributeType> providerAttributeTypes, String uuid) {
    ProviderRole obj = new ProviderRole();
    obj.setName(name);
    obj.setSuperviseeProviderRoles(superviseeProviderRoles);
    obj.setRelationshipTypes(relationshipTypes);
    obj.setProviderAttributeTypes(providerAttributeTypes);
    obj.setUuid(uuid);
    return obj;
}
Also used : ProviderRole(org.openmrs.module.providermanagement.ProviderRole)

Example 2 with ProviderRole

use of org.openmrs.module.providermanagement.ProviderRole 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)

Example 3 with ProviderRole

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

the class EditProviderPageController method get.

public void get(PageModel model, @MethodParam("getAccount") AccountDomainWrapper account, @ModelAttribute("patientId") @BindParams Patient patient, @SpringBean("patientService") PatientService patientService, @SpringBean("accountService") AccountService accountService, @SpringBean("adminService") AdministrationService administrationService, @SpringBean("providerManagementService") ProviderManagementService providerManagementService) throws PersonIsNotProviderException, InvalidRelationshipTypeException, SuggestionEvaluationException {
    model.addAttribute("account", account);
    List<ProviderRole> allProviderRoles = providerManagementService.getRestrictedProviderRoles(false);
    model.addAttribute("providerRoles", allProviderRoles);
    List<ProviderPersonRelationship> patientsList = new ArrayList<ProviderPersonRelationship>();
    List<RelationshipType> relationshipTypes = new ArrayList<RelationshipType>();
    Set<ProviderAttributeType> providerAttributeTypes = new HashSet<ProviderAttributeType>();
    List<ProviderPersonRelationship> supervisorsForProvider = null;
    List<ProviderPersonRelationship> superviseesForSupervisor = null;
    boolean isSupervisor = false;
    Provider provider = account.getProvider();
    if (provider != null) {
        if (!provider.getProviderRole().getSuperviseeProviderRoles().isEmpty()) {
            isSupervisor = true;
        }
        supervisorsForProvider = ProviderManagementUtils.getSupervisors(provider);
        superviseesForSupervisor = ProviderManagementUtils.getSupervisees(provider);
        ProviderRole providerRole = provider.getProviderRole();
        if (providerRole != null && providerRole.getRelationshipTypes() != null) {
            providerAttributeTypes = providerRole.getProviderAttributeTypes();
            Set<ProviderAttribute> attributes = provider.getAttributes();
            for (ProviderAttribute attribute : attributes) {
                // remove from the list of Attribute Types the ones that are already entered for this provider
                providerAttributeTypes.remove(attribute.getAttributeType());
            }
            for (RelationshipType relationshipType : provider.getProviderRole().getRelationshipTypes()) {
                if (!relationshipType.isRetired()) {
                    relationshipTypes.add(relationshipType);
                }
            }
            patientsList = ProviderManagementUtils.getAssignedPatients(provider);
        }
    } else {
        for (ProviderRole providerRole : allProviderRoles) {
            providerAttributeTypes.addAll(providerRole.getProviderAttributeTypes());
        }
    }
    boolean useAddressHierarchy = false;
    if (ModuleFactory.isModuleStarted("addresshierarchy")) {
        useAddressHierarchy = true;
    }
    model.addAttribute("relationshipTypes", relationshipTypes);
    model.addAttribute("patientsList", patientsList);
    model.addAttribute("providerAttributeTypes", providerAttributeTypes);
    model.addAttribute("isSupervisor", isSupervisor);
    model.addAttribute("supervisorsForProvider", supervisorsForProvider);
    model.addAttribute("superviseesForSupervisor", superviseesForSupervisor);
    model.addAttribute("superviseesForSupervisor", superviseesForSupervisor);
    model.addAttribute("useAddressHierarchy", useAddressHierarchy);
}
Also used : ProviderRole(org.openmrs.module.providermanagement.ProviderRole) ArrayList(java.util.ArrayList) RelationshipType(org.openmrs.RelationshipType) ProviderPersonRelationship(org.openmrs.module.providermanagement.relationship.ProviderPersonRelationship) Provider(org.openmrs.module.providermanagement.Provider) ProviderAttribute(org.openmrs.ProviderAttribute) ProviderAttributeType(org.openmrs.ProviderAttributeType) HashSet(java.util.HashSet)

Example 4 with ProviderRole

use of org.openmrs.module.providermanagement.ProviderRole in project openmrs-module-pihcore by PIH.

the class ProviderRoleBundle method install.

/**
 * Performs the installation of the metadata items
 *
 * @throws Exception if an error occurs
 */
@Override
public void install() throws Exception {
    Set<RelationshipType> relationshipTypes = null;
    RelationshipType vhwToPatient = personService.getRelationshipTypeByUuid(RelationshipTypeBundle.RelationshipTypes.CHW_TO_PATIENT);
    if (vhwToPatient != null) {
        relationshipTypes = new HashSet<RelationshipType>();
        relationshipTypes.add(vhwToPatient);
    }
    Set<ProviderAttributeType> providerAttributes = new HashSet<ProviderAttributeType>();
    ProviderAttributeType providerAttributeType = providerService.getProviderAttributeTypeByUuid(ProviderAttributeTypeBundle.ProviderAttributeTypes.DATE_HIRED);
    if (providerAttributeType != null) {
        providerAttributes.add(providerAttributeType);
    }
    providerAttributeType = providerService.getProviderAttributeTypeByUuid(ProviderAttributeTypeBundle.ProviderAttributeTypes.NUMBER_OF_HOUSEHOLDS);
    if (providerAttributeType != null) {
        providerAttributes.add(providerAttributeType);
    }
    ProviderRole vhwSupervisee = install(providerRole("CHW", null, relationshipTypes, providerAttributes, ProviderRoles.CHW));
    Set<ProviderRole> superviseeRoles = null;
    if (vhwSupervisee != null) {
        superviseeRoles = new HashSet<ProviderRole>();
        superviseeRoles.add(vhwSupervisee);
    }
    install(providerRole("CHW Supervisor", superviseeRoles, relationshipTypes, providerAttributes, ProviderRoles.CHW_SUPERVISOR));
}
Also used : RelationshipType(org.openmrs.RelationshipType) ProviderRole(org.openmrs.module.providermanagement.ProviderRole) ProviderAttributeType(org.openmrs.ProviderAttributeType) HashSet(java.util.HashSet)

Aggregations

ProviderRole (org.openmrs.module.providermanagement.ProviderRole)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ProviderAttributeType (org.openmrs.ProviderAttributeType)2 RelationshipType (org.openmrs.RelationshipType)2 Provider (org.openmrs.module.providermanagement.Provider)2 ProviderPersonRelationship (org.openmrs.module.providermanagement.relationship.ProviderPersonRelationship)2 HashMap (java.util.HashMap)1 List (java.util.List)1 ProviderAttribute (org.openmrs.ProviderAttribute)1 ProviderManagementService (org.openmrs.module.providermanagement.api.ProviderManagementService)1