/** * @see org.openmrs.api.EncounterService#retireEncounterRole(org.openmrs.EncounterRole, String) */ @Override public EncounterRole retireEncounterRole(EncounterRole encounterRole, String reason) throws APIException { if (reason == null) { throw new IllegalArgumentException("The 'reason' for retiring is required"); } return Context.getEncounterService().saveEncounterRole(encounterRole); }
/** * @see org.openmrs.api.EncounterService#unretireEncounterRole(org.openmrs.EncounterRole) */ @Override public EncounterRole unretireEncounterRole(EncounterRole encounterRole) throws APIException { return Context.getEncounterService().saveEncounterRole(encounterRole); }
/** * @see DelegatingCrudResource#save(java.lang.Object) */ @Override public EncounterRole save(EncounterRole encounterRole) { return Context.getEncounterService().saveEncounterRole(encounterRole); }
/** * @see EncounterService#getEncounterRoleByName(String) */ @Test public void getEncounterRoleByName_shouldFindEncounterRoleByName() { EncounterService encounterService = Context.getEncounterService(); EncounterRole encounterRole = new EncounterRole(); String name = "surgeon role"; encounterRole.setDescription("The surgeon"); encounterRole.setName(name); encounterRole = encounterService.saveEncounterRole(encounterRole); EncounterRole retrievedEncounterRole = encounterService.getEncounterRoleByName(name); assertNotNull("valid EncounterRole object should be returned", retrievedEncounterRole); assertEquals(encounterRole.getUuid(), retrievedEncounterRole.getUuid()); }
role = encounterService.saveEncounterRole(role);
role = Context.getEncounterService().saveEncounterRole(role); role2 = Context.getEncounterService().saveEncounterRole(role2);
/** * @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)); }
role = encounterService.saveEncounterRole(role);
role = encounterService.saveEncounterRole(role);
role = Context.getEncounterService().saveEncounterRole(role);
@Test public void testAdd() throws Exception { // If we don't explicitly set a locale, then a Context.getLocale() call nested somewhere below will trigger a // premature hibernate flush because it looks up the global property for default locale Context.setLocale(Locale.UK); EncounterRole newRole = new EncounterRole(); newRole.setName("Another role"); encounterService.saveEncounterRole(newRole); Encounter encounter = encounterService.getEncounter(3); EncounterProviderResource1_9 resource = getResource(); SimpleObject post = new SimpleObject().add("provider", "c2299800-cca9-11e0-9572-0800200c9a66").add("encounterRole", newRole.getUuid()); Object created = resource.create(encounter.getUuid(), post, new RequestContext()); assertThat((String) getByPath(created, "provider.uuid"), is("c2299800-cca9-11e0-9572-0800200c9a66")); assertThat((String) getByPath(created, "encounterRole.uuid"), is(newRole.getUuid())); assertThat(getEncounterProviderCountWithoutFlushing(), is(2)); assertThat(getEncounterProviderCountWithoutFlushingByUuid(getByPath(created, "uuid").toString()), is(1)); }