use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnTrueIfProperLocationTagAndUserHasConsultPrivilegeAndActiveVisit.
@Test
public void shouldReturnTrueIfProperLocationTagAndUserHasConsultPrivilegeAndActiveVisit() {
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(null);
when(visit.isActive()).thenReturn(true);
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.Location in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnFalseIfProperLocationTagAndUserHasConsultPrivilegeButNoActiveVisit.
@Test
public void shouldReturnFalseIfProperLocationTagAndUserHasConsultPrivilegeButNoActiveVisit() {
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(null);
when(visit.isActive()).thenReturn(false);
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(false));
}
use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnFalseIfLocationHasTagButVisitNotActive.
@Test
public void shouldReturnFalseIfLocationHasTagButVisitNotActive() {
Location sessionLocation = new Location();
SimpleObject sessionLocationRestRep = new SimpleObject();
sessionLocationRestRep.put("uuid", "123abc");
SimpleObject admitTag = new SimpleObject();
admitTag.put("display", LocationTags.ADMISSION_LOCATION.name());
sessionLocationRestRep.put("tags", Arrays.asList(admitTag));
PowerMockito.mockStatic(ConversionUtil.class);
when(ConversionUtil.convertToRepresentation(sessionLocation, Representation.DEFAULT)).thenReturn(sessionLocationRestRep);
VisitDomainWrapper visit = mock(VisitDomainWrapper.class);
when(visit.isActive()).thenReturn(false);
uiSessionContext.setSessionLocation(sessionLocation);
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(and(sessionLocationHasTag(LocationTags.ADMISSION_LOCATION), patientHasActiveVisit())), appContextModel), is(false));
}
use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class StandardPageController method post.
public String post(@RequestParam(value = "locationId", required = false) Integer locationId, @SpringBean("locationService") LocationService locationService, EmrContext context) {
Location location = locationService.getLocation(locationId);
context.setSessionLocation(location);
return null;
}
use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class LegacyMasterPatientIndexSetup method setupConnectionToMasterPatientIndex.
public static void setupConnectionToMasterPatientIndex(RuntimeProperties customProperties) {
String url = customProperties.getLacollineServerUrl();
String username = customProperties.getLacollineUsername();
String password = customProperties.getLacollinePassword();
if (url == null || username == null || password == null) {
log.warn("Not configuring link to Lacolline server (url, username, and password are required)");
return;
}
Map<String, PatientIdentifierType> identifierTypeMap = new HashMap<String, PatientIdentifierType>();
identifierTypeMap.put("a541af1e-105c-40bf-b345-ba1fd6a59b85", MetadataUtils.existing(PatientIdentifierType.class, PihHaitiPatientIdentifierTypes.ZL_EMR_ID.uuid()));
// TODO create PatientIdentifierType for Lacolline KE dossier number
identifierTypeMap.put("e66645eb-03a8-4991-b4ce-e87318e37566", MetadataUtils.existing(PatientIdentifierType.class, PihHaitiPatientIdentifierTypes.EXTERNAL_DOSSIER_NUMBER.uuid()));
// TODO create PatientIdentifierType for Lacolline dental dossier number
Map<String, Location> locationMap = new HashMap<String, Location>();
locationMap.put("23e7bb0d-51f9-4d5f-b34b-2fbbfeea1960", Context.getLocationService().getLocationByUuid(MirebalaisConstants.LACOLLINE_LOCATION_UUID));
Map<String, PersonAttributeType> attributeTypeMap = new HashMap<String, PersonAttributeType>();
attributeTypeMap.put("340d04c4-0370-102d-b0e3-001ec94a0cc1", MetadataUtils.existing(PersonAttributeType.class, HaitiPersonAttributeTypes.TELEPHONE_NUMBER.uuid()));
RemoteServerConfiguration config = new RemoteServerConfiguration();
config.setUrl(url);
config.setUsername(username);
config.setPassword(password);
config.setIdentifierTypeMap(identifierTypeMap);
config.setLocationMap(locationMap);
config.setAttributeTypeMap(attributeTypeMap);
Context.getService(ImportPatientFromWebService.class).registerRemoteServer("lacolline", config);
}
Aggregations