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);
}
}
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"));
}
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());
}
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());
}
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);
}
Aggregations