use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method searchEncounters_shouldNotAddResourcesForEmptyRevInclude.
@Test
public void searchEncounters_shouldNotAddResourcesForEmptyRevInclude() {
when(encounterService.searchForEncounters(any(), any(), any(), any(), any(), any(), any(), any(), any(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(encounter), PREFERRED_SIZE, COUNT));
HashSet<Include> revIncludes = new HashSet<>();
IBundleProvider results = resourceProvider.searchEncounter(null, null, null, null, null, null, null, null, null, null, revIncludes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.size(), equalTo(1));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.ENCOUNTER));
assertThat(((Encounter) resultList.iterator().next()).getId(), equalTo(ENCOUNTER_UUID));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method updateEncounter_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateEncounter_shouldThrowInvalidRequestForMissingId() {
Encounter noIdEncounter = new Encounter();
when(encounterService.update(ENCOUNTER_UUID, noIdEncounter)).thenThrow(InvalidRequestException.class);
resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), noIdEncounter);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method searchEncounters_shouldAddRelatedResourcesForRevInclude.
@Test
public void searchEncounters_shouldAddRelatedResourcesForRevInclude() {
when(encounterService.searchForEncounters(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Arrays.asList(encounter, new Observation()), PREFERRED_SIZE, COUNT));
HashSet<Include> revIncludes = new HashSet<>();
revIncludes.add(new Include("Observation:encounter"));
IBundleProvider results = resourceProvider.searchEncounter(null, null, null, null, null, null, null, null, null, null, revIncludes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.size(), greaterThanOrEqualTo(2));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.ENCOUNTER));
assertThat(resultList.get(1).fhirType(), equalTo(FhirConstants.OBSERVATION));
assertThat(((Encounter) resultList.iterator().next()).getId(), equalTo(ENCOUNTER_UUID));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method getEncounterHistory_shouldReturnProvenanceResources.
@Test
public void getEncounterHistory_shouldReturnProvenanceResources() {
IdType id = new IdType();
id.setValue(ENCOUNTER_UUID);
when(encounterService.get(ENCOUNTER_UUID)).thenReturn(encounter);
List<Resource> resources = resourceProvider.getEncounterHistoryById(id);
assertThat(resources, not(empty()));
assertThat(resources.stream().findAny().isPresent(), is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), Matchers.equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method searchEncounters_shouldReturnMatchingEncounters.
@Test
public void searchEncounters_shouldReturnMatchingEncounters() {
List<Encounter> encounters = new ArrayList<>();
encounters.add(encounter);
when(encounterService.searchForEncounters(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(encounters, PREFERRED_SIZE, COUNT));
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
subjectReference.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME)));
IBundleProvider results = resourceProvider.searchEncounter(null, null, null, subjectReference, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.ENCOUNTER));
assertThat(((Encounter) resultList.iterator().next()).getId(), equalTo(ENCOUNTER_UUID));
}
Aggregations