Search in sources :

Example 1 with ProviderAttributeType

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

the class ProviderAttributeTypeBundle method install.

/**
 * Performs the installation of the metadata items
 *
 * @throws Exception if an error occurs
 */
@Override
public void install() throws Exception {
    install(providerAttributeType("Households", "Number of households monitored by a VHW", FreeTextDatatype.class, null, 0, 1, ProviderAttributeTypes.NUMBER_OF_HOUSEHOLDS));
    ProviderAttributeType dateHired = install(providerAttributeType("Date Hired", "The date the provider was hired.", DateDatatype.class, null, 0, 1, ProviderAttributeTypes.DATE_HIRED));
    if (dateHired != null) {
        dateHired.setPreferredHandlerClassname("org.openmrs.web.attribute.handler.DateFieldGenDatatypeHandler");
        providerService.saveProviderAttributeType(dateHired);
    }
}
Also used : FreeTextDatatype(org.openmrs.customdatatype.datatype.FreeTextDatatype) DateDatatype(org.openmrs.customdatatype.datatype.DateDatatype) ProviderAttributeType(org.openmrs.ProviderAttributeType)

Example 2 with ProviderAttributeType

use of org.openmrs.ProviderAttributeType in project openmrs-core by openmrs.

the class ProviderValidatorTest method validate_shouldRejectAProviderIfItHasFewerThanMinOccursOfAnAttribute.

/**
 * @see ProviderValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldRejectAProviderIfItHasFewerThanMinOccursOfAnAttribute() {
    provider.setId(null);
    provider.setPerson(null);
    executeDataSet(PROVIDER_ATTRIBUTE_TYPES_XML);
    ProviderAttributeType attributeType = providerService.getProviderAttributeType(1);
    attributeType.setMinOccurs(2);
    attributeType.setMaxOccurs(3);
    providerService.saveProviderAttributeType(attributeType);
    provider.addAttribute(makeAttribute("one"));
    Errors errors = new BindException(provider, "provider");
    new ProviderValidator().validate(provider, errors);
    Assert.assertTrue(errors.hasFieldErrors("activeAttributes"));
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ProviderAttributeType(org.openmrs.ProviderAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 3 with ProviderAttributeType

use of org.openmrs.ProviderAttributeType in project openmrs-core by openmrs.

the class ProviderServiceTest method unretireProviderAttributeType_shouldUnretireAProviderAttributeType.

/**
 * @see ProviderService#unretireProviderAttributeType(ProviderAttributeType)
 */
@Test
public void unretireProviderAttributeType_shouldUnretireAProviderAttributeType() {
    ProviderAttributeType providerAttributeType = service.getProviderAttributeType(2);
    assertTrue(providerAttributeType.getRetired());
    service.unretireProviderAttributeType(providerAttributeType);
    assertFalse(providerAttributeType.getRetired());
    assertNull(providerAttributeType.getRetireReason());
}
Also used : ProviderAttributeType(org.openmrs.ProviderAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 4 with ProviderAttributeType

use of org.openmrs.ProviderAttributeType in project openmrs-core by openmrs.

the class ProviderServiceTest method getProviderAttributeTypeByUuid_shouldGetTheProviderAttributeTypeByItsUuid.

/**
 * @see ProviderService#getProviderAttributeTypeByUuid(String)
 */
@Test
public void getProviderAttributeTypeByUuid_shouldGetTheProviderAttributeTypeByItsUuid() {
    ProviderAttributeType providerAttributeType = service.getProviderAttributeTypeByUuid("9516cc50-6f9f-11e0-8414-001e378eb67e");
    assertEquals("Audit Date", providerAttributeType.getName());
}
Also used : ProviderAttributeType(org.openmrs.ProviderAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with ProviderAttributeType

use of org.openmrs.ProviderAttributeType 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)

Aggregations

ProviderAttributeType (org.openmrs.ProviderAttributeType)14 Test (org.junit.Test)9 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)9 BindException (org.springframework.validation.BindException)3 Errors (org.springframework.validation.Errors)3 HashSet (java.util.HashSet)2 ProviderAttribute (org.openmrs.ProviderAttribute)2 RelationshipType (org.openmrs.RelationshipType)2 FreeTextDatatype (org.openmrs.customdatatype.datatype.FreeTextDatatype)2 Provider (org.openmrs.module.providermanagement.Provider)2 ProviderRole (org.openmrs.module.providermanagement.ProviderRole)2 ArrayList (java.util.ArrayList)1 Criteria (org.hibernate.Criteria)1 Person (org.openmrs.Person)1 Provider (org.openmrs.Provider)1 APIException (org.openmrs.api.APIException)1 DateDatatype (org.openmrs.customdatatype.datatype.DateDatatype)1 InvalidRelationshipTypeException (org.openmrs.module.providermanagement.exception.InvalidRelationshipTypeException)1 PersonIsNotProviderException (org.openmrs.module.providermanagement.exception.PersonIsNotProviderException)1 SuggestionEvaluationException (org.openmrs.module.providermanagement.exception.SuggestionEvaluationException)1