/** * @see EncounterService#getEncounterRoleByUuid(String) */ @Test public void getEncounterRoleByUuid_shouldFindEncounterRoleBasedOnUuid() { EncounterService encounterService = Context.getEncounterService(); EncounterRole encounterRole = encounterService.getEncounterRoleByUuid("430bbb70-6a9c-4e1e-badb-9d1054b1b5e9"); assertNotNull("valid uuid should be returned", encounterRole); encounterRole = encounterService.getEncounterRoleByUuid("invaid uuid"); assertNull("returns null for invalid uuid", encounterRole); }
/** * @see ORUR01Handler#processMessage(Message) */ @Test public void processMessage_shouldCreateAnEncounterAndFindTheProviderByPersonId() throws Exception { int patientId = 2; Patient patient = new Patient(patientId); List<Encounter> encForPatient1 = Context.getEncounterService().getEncountersByPatient(patient); String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||" + patientId + "^^^^||Hornblower^Horatio^Test||\r" + "PV1||O|1^Unknown Location||||1^name|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT"; Message hl7message = parser.parse(hl7string); router.processMessage(hl7message); List<Encounter> encForPatient2 = Context.getEncounterService().getEncountersByPatient(patient); assertTrue("An encounter should have been created", (encForPatient1.size() + 1) == encForPatient2.size()); encForPatient2.removeAll(encForPatient1); Assert.assertTrue(encForPatient2.size() == 1); Provider newProvider = encForPatient2.get(0).getProvidersByRole( Context.getEncounterService().getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID)).iterator() .next(); Assert.assertEquals("c2299800-cca9-11e0-9572-0800200c9a66", newProvider.getUuid()); }
Context.getEncounterService().getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID)).iterator() .next(); Assert.assertEquals("a2c3868a-6b90-11e0-93c3-18a905e044dc", newProvider.getUuid());
Context.getEncounterService().getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID)).iterator() .next(); Assert.assertEquals("1f9e8336-6b95-11e0-93c3-18a905e044dc", newProvider.getUuid());
Context.getEncounterService().getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID)).iterator() .next(); Assert.assertEquals(4, newProvider.getId().intValue());
/** * Fetches a encounterRole by uuid, if no match is found, it tries to look up one with a * matching name with the assumption that the passed parameter is a encounterRole name * * @see DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public EncounterRole getByUniqueId(String uuid) { return Context.getEncounterService().getEncounterRoleByUuid(uuid); }
if (unknownRole == null) { unknownRole = Context.getEncounterService() .getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID);
public static void setProvider(Encounter encounter, Person provider) { EncounterRole unknownRole = Context.getEncounterService().getEncounterRoleByUuid( EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID); if (unknownRole == null) { throw new IllegalStateException("No 'Unknown' encounter role with uuid " + EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID + "."); } Collection<Provider> providers = Context.getProviderService().getProvidersByPerson(provider); if (providers == null || providers.isEmpty()) { throw new IllegalArgumentException("No provider with personId " + provider.getPersonId()); } encounter.setProvider(unknownRole, providers.iterator().next()); } }
@Override public EncounterRole newObject() { return Context.getEncounterService().getEncounterRoleByUuid(getUuidProperty()); }
@Override public EncounterRole newObject() { return Context.getEncounterService().getEncounterRoleByUuid(getUuidProperty()); }
encounterRole = es.getEncounterRole(Integer.valueOf(param)); } catch (Exception ex) { encounterRole = es.getEncounterRoleByUuid(param);
@Test public void testExportWithEncounterRoleAndProvider() throws Exception { HtmlForm form = new HtmlForm(); form.setXmlData(new TestUtil().loadXmlFromFile("org/openmrs/module/htmlformentry/include/metadataSharingExportTest.xml")); HtmlFormExporter exporter = new HtmlFormExporter(form); HtmlForm formClone = exporter.export(true, true, true, true); Collection<OpenmrsObject> dependencies = formClone.getDependencies(); Assert.assertTrue(dependencies.contains(Context.getEncounterService().getEncounterRoleByUuid("e5c5cc92-5283-11e1-bb6a-d975bd577a5e"))); Assert.assertTrue(dependencies.contains(Context.getEncounterService().getEncounterRoleByUuid("eb75d754-5283-11e1-bb6a-d975bd577a5e"))); Assert.assertTrue(dependencies.contains(Context.getProviderService().getProviderByUuid("d2299800-cca9-11e0-9572-0800200c9a66"))); Assert.assertTrue(dependencies.contains(Context.getProviderService().getProviderByUuid("c2299800-cca9-11e0-9572-0800200c9a66"))); }
@Test public void shouldEditingAnEncounterRole() throws Exception { final String newName = "updated name"; SimpleObject encounterRole = new SimpleObject(); encounterRole.add("name", newName); String json = new ObjectMapper().writeValueAsString(encounterRole); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); assertEquals(newName, service.getEncounterRoleByUuid(getUuid()).getName()); }
@Test public void shouldRetireAEncounterRole() throws Exception { assertEquals(false, service.getEncounterRoleByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req); assertEquals(true, service.getEncounterRoleByUuid(getUuid()).isRetired()); assertEquals(reason, service.getEncounterRoleByUuid(getUuid()).getRetireReason()); }
@Test public void shouldGetAnEncounterRoleByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); EncounterRole encounterRole = service.getEncounterRoleByUuid(getUuid()); assertEquals(encounterRole.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(encounterRole.getName(), PropertyUtils.getProperty(result, "name")); assertEquals(encounterRole.getDescription(), PropertyUtils.getProperty(result, "description")); }
Assert.assertNotEquals(existing.getEncounterRole(), es.getEncounterRoleByUuid(newRoleUuid)); Assert.assertEquals(es.getEncounterRoleByUuid(newRoleUuid), updateEncounterProvider.getEncounterRole());