/** * Gets the system default location specified as a global property. * * @return default location object. * @should return the updated defaultLocation when the value of the global property is changed */ public static Location getDefaultLocation() { if (defaultLocation == null && Context.isSessionOpen()) { defaultLocation = Context.getLocationService().getDefaultLocation(); } return defaultLocation; }
obsExit.setConcept(reasonForExit); Location loc = Context.getLocationService().getDefaultLocation();
obsDeath.setPerson(patient); obsDeath.setConcept(causeOfDeath); Location location = Context.getLocationService().getDefaultLocation(); if (location != null) { obsDeath.setLocation(location);
@Test public void processDeath_shouldMapValuesAndSavePatient() throws Exception { // given final Date dateDied = new Date(); final Concept causeOfDeath = new Concept(2); when(conceptService.getConcept(anyString())).thenReturn(new Concept()); when(locationService.getDefaultLocation()).thenReturn(new Location()); UserContext userContext = mock(UserContext.class); this.contextMockHelper.setUserContext(userContext); when(userContext.hasPrivilege(anyString())).thenReturn(true); ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class); when(patientDaoMock.savePatient(argumentCaptor.capture())).thenReturn(new Patient()); // when final Patient patient = new Patient(); patient.addIdentifier(new PatientIdentifier("an identifier", new PatientIdentifierType(1234), new Location())); patientService.processDeath(patient, dateDied, causeOfDeath, "unknown"); // then final Patient savedPatient = argumentCaptor.getValue(); assertEquals(true, savedPatient.getDead()); assertEquals(dateDied, savedPatient.getDeathDate()); assertEquals(causeOfDeath, savedPatient.getCauseOfDeath()); }
Location location = Context.getLocationService().getDefaultLocation(); if (location == null) { throw new HL7Exception("Cannot find default location");
Location location = Context.getLocationService().getDefaultLocation(); if (location == null) { throw new HL7Exception("Cannot find default location");
/** * @see LocationService#getDefaultLocation() */ @Test public void getDefaultLocation_shouldReturnDefaultLocationForTheImplementation() { //set the global property for default location to something other than Unknown Location GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "Test Parent Location", "Testing default Location"); Context.getAdministrationService().saveGlobalProperty(gp); Assert.assertEquals("Test Parent Location", Context.getLocationService().getDefaultLocation().getName()); }
/** * @see LocationService#getDefaultLocation() */ @Test public void getDefaultLocation_shouldReturnUnknownLocationIfTheGlobalPropertyIsSomethingElseThatDoesnotExist() { //set the global property to something that has no match in the location table GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "None existent Location", "Testing"); Context.getAdministrationService().saveGlobalProperty(gp); Assert.assertEquals("Unknown Location", Context.getLocationService().getDefaultLocation().getName()); }
location= Context.getLocationService().getDefaultLocation(); if (location != null) { return location;