Search in sources :

Example 71 with Location

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));
}
Also used : SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Config(org.openmrs.module.pihcore.config.Config) Location(org.openmrs.Location) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 72 with Location

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));
}
Also used : SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Config(org.openmrs.module.pihcore.config.Config) Location(org.openmrs.Location) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 73 with Location

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));
}
Also used : SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Location(org.openmrs.Location) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 74 with Location

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;
}
Also used : Location(org.openmrs.Location)

Example 75 with Location

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);
}
Also used : RemoteServerConfiguration(org.openmrs.module.importpatientfromws.api.RemoteServerConfiguration) HashMap(java.util.HashMap) PersonAttributeType(org.openmrs.PersonAttributeType) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) ImportPatientFromWebService(org.openmrs.module.importpatientfromws.api.ImportPatientFromWebService)

Aggregations

Location (org.openmrs.Location)235 Test (org.junit.Test)161 Date (java.util.Date)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)74 Patient (org.openmrs.Patient)66 Encounter (org.openmrs.Encounter)38 SimpleObject (org.openmrs.ui.framework.SimpleObject)32 PatientIdentifierType (org.openmrs.PatientIdentifierType)31 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)31 Visit (org.openmrs.Visit)28 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)28 Obs (org.openmrs.Obs)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 PatientIdentifier (org.openmrs.PatientIdentifier)26 Concept (org.openmrs.Concept)19 EncounterType (org.openmrs.EncounterType)18 DateTime (org.joda.time.DateTime)17 ArrayList (java.util.ArrayList)15 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)15 BindException (org.springframework.validation.BindException)15