use of org.openmrs.module.fhir2.api.translators.EncounterTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirEncounterServiceImplTest method searchForEncounter_shouldReturnCollectionOfEncounterByParticipant.
@Test
public void searchForEncounter_shouldReturnCollectionOfEncounterByParticipant() {
ReferenceAndListParam participant = new ReferenceAndListParam();
participant.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue(PARTICIPANT_IDENTIFIER).setChain(Practitioner.SP_IDENTIFIER)));
List<Encounter> encounters = new ArrayList<>();
encounters.add(openMrsEncounter);
fhirEncounter.setId(ENCOUNTER_UUID);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participant);
when(dao.getSearchResults(any(), any())).thenReturn(encounters);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ENCOUNTER_UUID));
when(encounterTranslator.toFhirResource(openMrsEncounter)).thenReturn(fhirEncounter);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, encounterTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(visitService.searchForVisits(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = encounterService.searchForEncounters(null, null, participant, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.openmrs.module.fhir2.api.translators.EncounterTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirEncounterServiceImplTest method searchForEncounter_shouldReturnCollectionOfEncounterByTypeUUID.
@Test
public void searchForEncounter_shouldReturnCollectionOfEncounterByTypeUUID() {
TokenAndListParam typeUuid = new TokenAndListParam().addAnd(new TokenParam(ENCOUNTER_TYPE_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ENCOUNTER_TYPE_REFERENCE_SEARCH_HANDLER, typeUuid);
List<Encounter> encounters = new ArrayList<>();
encounters.add(openMrsEncounter);
fhirEncounter.setId(ENCOUNTER_UUID);
when(dao.getSearchResults(any(), any())).thenReturn(encounters);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ENCOUNTER_UUID));
when(encounterTranslator.toFhirResource(openMrsEncounter)).thenReturn(fhirEncounter);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, encounterTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(visitService.searchForVisits(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = encounterService.searchForEncounters(null, null, null, null, typeUuid, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations