use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.
the class MirebalaisHospitalActivator method contextRefreshed.
/**
* @see ModuleActivator#contextRefreshed()
*/
public void contextRefreshed() {
try {
// currently only one of these
Config config = Context.getRegisteredComponents(Config.class).get(0);
// Reload configuration based on runtime properties values, defaulting to mirebalais if nothing found
String configs = Context.getRuntimeProperties().getProperty(ConfigLoader.PIH_CONFIGURATION_RUNTIME_PROPERTY, "mirebalais");
config.reload(ConfigLoader.load(configs));
log.info("Mirebalais Hospital Module refreshed");
} catch (Exception e) {
Module mod = ModuleFactory.getModuleById(MirebalaisConstants.MIREBALAIS_MODULE_ID);
ModuleFactory.stopModule(mod);
throw new RuntimeException("failed to setup the required modules", e);
}
}
use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnTrueIfVisitWithinPastThirtyDays.
@Test
public void shouldReturnTrueIfVisitWithinPastThirtyDays() {
VisitContextModel visit = mock(VisitContextModel.class);
when(visit.getStopDatetimeInMilliseconds()).thenReturn(new Date().getTime());
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
Config config = mock(Config.class);
when(config.isComponentEnabled("visitNote")).thenReturn(false);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(patientVisitWithinPastThirtyDays(config)), appContextModel), is(true));
}
use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilegeThisProviderOnlyAndVisitInLastThirtyDays.
@Test
public void shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilegeThisProviderOnlyAndVisitInLastThirtyDays() {
// doctor has last thirty days privilege
user.addRole(doctor);
Location sessionLocation = new Location();
SimpleObject sessionLocationRestRep = new SimpleObject();
sessionLocationRestRep.put("uuid", "123abc");
SimpleObject admitTag = new SimpleObject();
admitTag.put("display", LocationTags.CONSULT_NOTE_LOCATION.name());
sessionLocationRestRep.put("tags", Arrays.asList(admitTag));
PowerMockito.mockStatic(ConversionUtil.class);
when(ConversionUtil.convertToRepresentation(sessionLocation, Representation.DEFAULT)).thenReturn(sessionLocationRestRep);
VisitContextModel visit = mock(VisitContextModel.class);
when(visit.getStopDatetimeInMilliseconds()).thenReturn(new DateTime().getMillis());
uiSessionContext.setSessionLocation(sessionLocation);
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
Config config = mock(Config.class);
when(config.isComponentEnabled("visitNote")).thenReturn(false);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(and(sessionLocationHasTag(LocationTags.CONSULT_NOTE_LOCATION), or(and(userHasPrivilege(Privileges.TASK_EMR_ENTER_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config))))), appContextModel), is(true));
}
use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilege.
@Test
public void shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilege() {
user.addRole(admin);
Location sessionLocation = new Location();
SimpleObject sessionLocationRestRep = new SimpleObject();
sessionLocationRestRep.put("uuid", "123abc");
SimpleObject admitTag = new SimpleObject();
admitTag.put("display", LocationTags.CONSULT_NOTE_LOCATION.name());
sessionLocationRestRep.put("tags", Arrays.asList(admitTag));
PowerMockito.mockStatic(ConversionUtil.class);
when(ConversionUtil.convertToRepresentation(sessionLocation, Representation.DEFAULT)).thenReturn(sessionLocationRestRep);
VisitContextModel visit = mock(VisitContextModel.class);
when(visit.getStopDatetimeInMilliseconds()).thenReturn(new DateTime(2014, 1, 1, 1, 1).getMillis());
uiSessionContext.setSessionLocation(sessionLocation);
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
Config config = mock(Config.class);
when(config.isComponentEnabled("visitNote")).thenReturn(false);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(and(sessionLocationHasTag(LocationTags.CONSULT_NOTE_LOCATION), or(and(userHasPrivilege(Privileges.TASK_EMR_ENTER_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config))))), appContextModel), is(true));
}
use of org.openmrs.module.pihcore.config.Config in project openmrs-module-pihcore by PIH.
the class PihRadiologyOrdersMergeActionsComponentTest method shouldMergePatientsWhenNonPreferredPatientHasOnlyRadiologyOrders.
@Test
public void shouldMergePatientsWhenNonPreferredPatientHasOnlyRadiologyOrders() throws Exception {
PihRadiologyOrdersMergeActions pihRadiologyOrdersMergeActions = Context.getRegisteredComponent("pihRadiologyOrdersMergeActions", PihRadiologyOrdersMergeActions.class);
Config config = mock(Config.class);
runtimeProperties.setProperty(ConfigLoader.PIH_CONFIGURATION_RUNTIME_PROPERTY, "mirebalais");
config = new Config(ConfigLoader.loadFromRuntimeProperties());
pihRadiologyOrdersMergeActions.setConfig(config);
Patient preferredPatient = patientService.getPatient(6);
Patient nonPreferredPatient = patientService.getPatient(10003);
List<Encounter> encountersByPatient = encounterService.getEncountersByPatient(nonPreferredPatient);
// patient has 1 Radiology Encounter
Assert.assertEquals(1, encountersByPatient.size());
Assert.assertEquals("RadiologyOrder", encountersByPatient.get(0).getEncounterType().getName());
Set<Order> orders = encountersByPatient.get(0).getOrders();
Assert.assertEquals(1, orders.size());
Order radiologyOrder = null;
for (Order order : orders) {
radiologyOrder = order;
}
Assert.assertEquals("RadiologyOrder", radiologyOrder.getOrderType().getName());
adtService.mergePatients(preferredPatient, nonPreferredPatient);
assertTrue("RadiologyOrder was not merged", orderService.getAllOrdersByPatient(preferredPatient).contains(radiologyOrder));
}
Aggregations