/** * No types should be returned when using a substring other than the starting substring * * @see EncounterService#findEncounterTypes(String) */ @Test public void findEncounterTypes_shouldNotPartialMatchNameOnInternalSubstrings() { EncounterService encounterService = Context.getEncounterService(); List<EncounterType> types = encounterService.findEncounterTypes("Test Enc Type"); assertEquals(3, types.size()); types = encounterService.findEncounterTypes("Enc Type"); assertEquals(0, types.size()); }
/** * @see EncounterService#findEncounterTypes(String) */ @Test public void findEncounterTypes_shouldReturnTypesByPartialNameMatch() { EncounterService encounterService = Context.getEncounterService(); List<EncounterType> types = encounterService.findEncounterTypes("Test Enc"); assertEquals(3, types.size()); }
/** * @see EncounterService#findEncounterTypes(String) */ @Test public void findEncounterTypes_shouldReturnTypesByPartialCaseInsensitiveMatch() { EncounterService encounterService = Context.getEncounterService(); List<EncounterType> types = encounterService.findEncounterTypes("Test ENC"); assertEquals(3, types.size()); }
/** * @see EncounterService#findEncounterTypes(String) */ @Test public void findEncounterTypes_shouldReturnTypesOrderedOnNameAndNonretiredFirst() { EncounterService encounterService = Context.getEncounterService(); List<EncounterType> types = encounterService.findEncounterTypes("Test Enc"); // make sure the order is id 2, 3, 1 assertEquals(2, types.get(0).getEncounterTypeId().intValue()); assertEquals(1, types.get(1).getEncounterTypeId().intValue()); assertEquals(3, types.get(2).getEncounterTypeId().intValue()); }
/** * @see EncounterService#findEncounterTypes(String) */ @Test public void findEncounterTypes_shouldIncludeRetiredTypesInTheResults() { EncounterService encounterService = Context.getEncounterService(); List<EncounterType> types = encounterService.findEncounterTypes("Test Enc"); assertEquals(3, types.size()); // make sure at least one of the types was retired boolean foundRetired = false; for (EncounterType type : types) { if (type.getRetired()) foundRetired = true; } assertTrue("Retired types should be returned as well", foundRetired); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<EncounterType> doSearch(RequestContext context) { return new NeedsPaging<EncounterType>(Context.getEncounterService().findEncounterTypes(context.getParameter("q")), context); } }