use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderIntegrationTest method shouldReturnRelatedPersonAsJson.
@Test
public void shouldReturnRelatedPersonAsJson() throws Exception {
MockHttpServletResponse response = get("/RelatedPerson/" + RELATIONSHIP_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
RelatedPerson relatedPerson = readResponse(response);
assertThat(relatedPerson, notNullValue());
assertThat(relatedPerson.getIdElement().getIdPart(), equalTo(RELATIONSHIP_UUID));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderIntegrationTest method shouldReturnSortedAndFilterSearchResultsForRelatedPersonAsXML.
@Test
public void shouldReturnSortedAndFilterSearchResultsForRelatedPersonAsXML() throws Exception {
MockHttpServletResponse response = get("/RelatedPerson?name=John&_sort=-date").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("nameFirstRep", hasProperty("family", containsString("Doe"))))));
assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("nameFirstRep", hasProperty("givenAsSingleString", containsString("F"))))));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method getRelatedPersonById_shouldReturnMatchingRelatedPerson.
@Test
public void getRelatedPersonById_shouldReturnMatchingRelatedPerson() {
when(relatedPersonService.get(RELATED_PERSON_UUID)).thenReturn(relatedPerson);
IdType id = new IdType();
id.setValue(RELATED_PERSON_UUID);
RelatedPerson relatedPerson = resourceProvider.getRelatedPersonById(id);
assertThat(relatedPerson, notNullValue());
assertThat(relatedPerson.getId(), notNullValue());
assertThat(relatedPerson.getId(), equalTo(RELATED_PERSON_UUID));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByUUID.
@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByUUID() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(RELATED_PERSON_UUID));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(uuid)), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, null, null, uuid, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method initRelatedPerson.
@Before
public void initRelatedPerson() {
HumanName name = new HumanName();
name.addGiven(GIVEN_NAME);
name.setFamily(FAMILY_NAME);
relatedPerson = new RelatedPerson();
relatedPerson.setId(RELATED_PERSON_UUID);
relatedPerson.setGender(Enumerations.AdministrativeGender.MALE);
relatedPerson.addName(name);
setProvenanceResources(relatedPerson);
}
Aggregations