Search in sources :

Example 41 with Person

use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByLastUpdated.

@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByLastUpdated() {
    DateRangeParam lastUpdated = new DateRangeParam().setLowerBound(LAST_UPDATED_DATE).setUpperBound(LAST_UPDATED_DATE);
    when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(lastUpdated)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, null, null, lastUpdated, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.Test)

Example 42 with Person

use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method getPatientResourceHistory_shouldReturnListOfResource.

@Test
public void getPatientResourceHistory_shouldReturnListOfResource() {
    IdType id = new IdType();
    id.setValue(PERSON_UUID);
    when(fhirPersonService.get(PERSON_UUID)).thenReturn(person);
    List<Resource> resources = resourceProvider.getPersonHistoryById(id);
    assertThat(resources, notNullValue());
    assertThat(resources, not(empty()));
    assertThat(resources.size(), equalTo(2));
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.dstu3.model.Resource) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 43 with Person

use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method getPersonById_shouldReturnPerson.

@Test
public void getPersonById_shouldReturnPerson() {
    IdType id = new IdType();
    id.setValue(PERSON_UUID);
    when(fhirPersonService.get(PERSON_UUID)).thenReturn(person);
    Person result = resourceProvider.getPersonById(id);
    assertThat(result.isResource(), is(true));
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(PERSON_UUID));
}
Also used : Person(org.hl7.fhir.dstu3.model.Person) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 44 with Person

use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method initPerson.

@Before
public void initPerson() {
    HumanName name = new HumanName();
    name.addGiven(GIVEN_NAME);
    name.setFamily(FAMILY_NAME);
    person = new org.hl7.fhir.r4.model.Person();
    person.setId(PERSON_UUID);
    person.setGender(Enumerations.AdministrativeGender.MALE);
    person.addName(name);
    setProvenanceResources(person);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Before(org.junit.Before)

Example 45 with Person

use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByCity.

@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByCity() {
    StringAndListParam cityParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
    when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), argThat(is(cityParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchPeople(null, null, null, cityParam, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)181 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)54 Date (java.util.Date)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)48 Person (org.hl7.fhir.r4.model.Person)47 Person (model.Person)44 Person (com.google.api.services.people.v1.model.Person)38 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)32 Reference (org.hl7.fhir.r4.model.Reference)31 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)30 StringParam (ca.uhn.fhir.rest.param.StringParam)30 VCard (ezvcard.VCard)30 Person (org.openmrs.Person)29 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)23 List (java.util.List)22 Collectors (java.util.stream.Collectors)22 Person (org.hl7.fhir.dstu3.model.Person)22 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)22 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)21