/** * Make sure that purging an encounter removes the row from the database * * @see EncounterService#purgeEncounterRole(org.openmrs.EncounterRole) */ @Test public void purgeEncounterRole_shouldPurgeEncounterRole() { EncounterService encounterService = Context.getEncounterService(); EncounterRole encounterRole = encounterService.getEncounterRole(1); encounterService.purgeEncounterRole(encounterRole); EncounterRole fetchedEncounterRole = encounterService.getEncounterRole(encounterRole.getEncounterRoleId()); assertNull("We shouldn't find the encounter after deletion", fetchedEncounterRole); }
String param = parameters.get("encounterRole"); try { encounterRole = es.getEncounterRole(Integer.valueOf(param)); } catch (Exception ex) { encounterRole = es.getEncounterRoleByUuid(param);
/** * @see EncounterService#retireEncounterRole(org.openmrs.EncounterRole, String) */ @Test(expected = IllegalArgumentException.class) public void retireEncounterRole_shouldThrowErrorIfGivenNullReasonParameter() { EncounterService encounterService = Context.getEncounterService(); EncounterRole encounterRole = encounterService.getEncounterRole(1); encounterService.retireEncounterRole(encounterRole, null); }
private Encounter buildEncounter() { // First, create a new Encounter Encounter enc = new Encounter(); enc.setLocation(Context.getLocationService().getLocation(1)); enc.setEncounterType(Context.getEncounterService().getEncounterType(1)); enc.setEncounterDatetime(new Date()); enc.setPatient(Context.getPatientService().getPatient(3)); enc.addProvider(Context.getEncounterService().getEncounterRole(1), Context.getProviderService().getProvider(1)); return enc; }
/** * @see org.openmrs.module.htmlformentry.widget.Widget#getValue(org.openmrs.module.htmlformentry.FormEntryContext, javax.servlet.http.HttpServletRequest) */ @Override public Object getValue(FormEntryContext context, HttpServletRequest request) { String val = request.getParameter(context.getFieldName(this)); if (StringUtils.hasText(val)) { return Context.getEncounterService().getEncounterRole(Integer.valueOf(val)); } return null; }
/** * @see org.openmrs.api.EncounterService#saveEncounterRole(org.openmrs.EncounterRole) */ @Test public void saveEncounterRole_shouldSaveEncounterRoleWithBasicDetails() { EncounterRole encounterRole = new EncounterRole(); encounterRole.setName("Attending physician"); encounterRole.setDescription("The person in charge"); EncounterService encounterService = Context.getEncounterService(); encounterService.saveEncounterRole(encounterRole); assertNotNull("The saved encounter role should have an encounter role id now", encounterRole.getEncounterRoleId()); EncounterRole newSavedEncounterRole = encounterService.getEncounterRole(encounterRole.getEncounterRoleId()); assertNotNull("We should get back an encounter role", newSavedEncounterRole); assertEquals(encounterRole, newSavedEncounterRole); assertTrue("The created encounter role needs to equal the pojo encounter role", encounterRole.equals(newSavedEncounterRole)); }
/** * @see EncounterService#unretireEncounterRole(org.openmrs.EncounterRole) */ @Test public void unretireEncounterRole_shouldUnretireTypeAndUnmarkAttributes() { EncounterService encounterService = Context.getEncounterService(); EncounterRole encounterRole = encounterService.getEncounterRole(2); assertTrue(encounterRole.getRetired()); assertNotNull(encounterRole.getRetiredBy()); assertNotNull(encounterRole.getRetireReason()); assertNotNull(encounterRole.getDateRetired()); EncounterRole unretiredEncounterRole = encounterService.unretireEncounterRole(encounterRole); assertEquals(unretiredEncounterRole, encounterRole); assertFalse(unretiredEncounterRole.getRetired()); assertNull(unretiredEncounterRole.getDateRetired()); assertNull(unretiredEncounterRole.getRetiredBy()); assertNull(unretiredEncounterRole.getRetireReason()); }
/** * @see EncounterService#retireEncounterRole(org.openmrs.EncounterRole, String) */ @Test public void retireEncounterRole_shouldRetireTypeAndSetAttributes() { EncounterService encounterService = Context.getEncounterService(); EncounterRole encounterRole = encounterService.getEncounterRole(1); assertFalse(encounterRole.getRetired()); assertNull(encounterRole.getRetiredBy()); assertNull(encounterRole.getRetireReason()); assertNull(encounterRole.getDateRetired()); EncounterRole retiredEncounterRole = encounterService.retireEncounterRole(encounterRole, "Just Testing"); assertEquals(retiredEncounterRole, encounterRole); assertTrue(retiredEncounterRole.getRetired()); assertNotNull(retiredEncounterRole.getDateRetired()); assertEquals(Context.getAuthenticatedUser(), retiredEncounterRole.getRetiredBy()); assertEquals("Just Testing", retiredEncounterRole.getRetireReason()); }
@Override public void testEditedResults(SubmissionResults results) { results.assertNoErrors(); results.assertLocation(2); Map<EncounterRole, Set<Provider>> byRoles = results.getEncounterCreated().getProvidersByRoles(); Assert.assertEquals(1, byRoles.size()); Set<Provider> doctors = byRoles.get(Context.getEncounterService().getEncounterRole(3)); Assert.assertEquals(1, doctors.size()); Assert.assertEquals(1, doctors.size()); Assert.assertEquals(new Integer(1), doctors.iterator().next().getId()); } }.run();
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertLocation(2); Map<EncounterRole, Set<Provider>> byRoles = results.getEncounterCreated().getProvidersByRoles(); Assert.assertEquals(2, byRoles.size()); Set<Provider> doctors = byRoles.get(Context.getEncounterService().getEncounterRole(3)); Set<Provider> nurses = byRoles.get(Context.getEncounterService().getEncounterRole(2)); Assert.assertEquals(1, doctors.size()); Assert.assertEquals(1, nurses.size()); Assert.assertEquals(2, (int) doctors.iterator().next().getProviderId()); Assert.assertEquals(1, (int) nurses.iterator().next().getProviderId()); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertLocation(2); Map<EncounterRole, Set<Provider>> byRoles = results.getEncounterCreated().getProvidersByRoles(); Assert.assertEquals(1, byRoles.size()); Set<Provider> doctors = byRoles.get(Context.getEncounterService().getEncounterRole(3)); Assert.assertEquals(1, doctors.size()); Assert.assertEquals(new Integer(2), doctors.iterator().next().getId()); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertLocation(2); Map<EncounterRole, Set<Provider>> byRoles = results.getEncounterCreated().getProvidersByRoles(); Assert.assertEquals(1, byRoles.size()); Set<Provider> doctors = byRoles.get(Context.getEncounterService().getEncounterRole(3)); Assert.assertEquals(2, doctors.size()); // we can't guarantee the order of providers, but make sure both providers are now present Set<Integer> providerIds = new HashSet<Integer>(); for (Provider doctor : doctors) { providerIds.add(doctor.getId()); } Assert.assertEquals(2, providerIds.size()); Assert.assertTrue(providerIds.contains(1)); Assert.assertTrue(providerIds.contains(2)); }