use of org.openmrs.module.providermanagement.Provider in project openmrs-module-pihcore by PIH.
the class PihProviderIdentifierGeneratorTest method shouldFailForVeryHighId.
// we are generating a 3-digit base 30 number, which gives us 27000 possible combinations
// after that, things will start to fail
@Test(expected = RuntimeException.class)
public void shouldFailForVeryHighId() {
when(config.getProviderIdentifierPrefix()).thenReturn("M");
Provider provider = new Provider();
provider.setId(1000000);
String identifier = (generator).generateIdentifier(provider);
}
use of org.openmrs.module.providermanagement.Provider in project openmrs-module-pihcore by PIH.
the class PihProviderIdentifierGeneratorTest method shouldGenerateIdentifierWithTwoDigitPrefix.
@Test
public void shouldGenerateIdentifierWithTwoDigitPrefix() {
when(config.getProviderIdentifierPrefix()).thenReturn("PL");
Provider provider = new Provider();
provider.setId(26000);
String identifier = (generator).generateIdentifier(provider);
Assert.assertEquals("PL971Y", identifier);
}
use of org.openmrs.module.providermanagement.Provider in project openmrs-module-pihcore by PIH.
the class PihProviderIdentifierGeneratorTest method shouldNotFailForHighId.
@Test
public void shouldNotFailForHighId() {
when(config.getProviderIdentifierPrefix()).thenReturn("M");
Provider provider = new Provider();
provider.setId(30000);
String identifier = (generator).generateIdentifier(provider);
Assert.assertEquals("MCEMA2", identifier);
}
use of org.openmrs.module.providermanagement.Provider 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);
}
use of org.openmrs.module.providermanagement.Provider 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