Search in sources :

Example 31 with Person

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

the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleForMatchOnCity.

@Test
public void shouldReturnCollectionOfPeopleForMatchOnCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city);
    IBundleProvider people = search(theParams);
    assertThat(people, notNullValue());
    assertThat(people.size(), greaterThanOrEqualTo(1));
    List<Person> resultList = get(people);
    assertThat(resultList, not(empty()));
    assertThat(resultList.get(0).getAddressFirstRep().getCity(), equalTo(CITY));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Person(org.hl7.fhir.r4.model.Person) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 32 with Person

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

the class PersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnPersonName.

@Test
public void shouldReturnEmptyCollectionForNoMatchOnPersonName() {
    StringAndListParam personName = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_FOUND_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.NAME_PROPERTY, personName);
    IBundleProvider people = search(theParams);
    assertThat(people, notNullValue());
    assertThat(people.size(), equalTo(0));
    List<Person> resultList = get(people);
    assertThat(resultList, is(empty()));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Person(org.hl7.fhir.r4.model.Person) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 33 with Person

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

the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleSortedByState.

@Test
public void shouldReturnCollectionOfPeopleSortedByState() throws Exception {
    executeDataSet(ADDRESS_SEARCH_FILE);
    SortSpec sort = new SortSpec();
    sort.setParamName(SP_ADDRESS_STATE);
    sort.setOrder(SortOrderEnum.ASC);
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, new StringAndListParam().addAnd(new StringParam("M"))).setSortSpec(sort);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThan(1));
    List<Person> people = get(results);
    assertThat(people, hasSize(greaterThan(1)));
    for (int i = 1; i < people.size(); i++) {
        assertThat(people.get(i - 1).getAddressFirstRep().getState(), lessThanOrEqualTo(people.get(i).getAddressFirstRep().getState()));
    }
    sort.setOrder(SortOrderEnum.DESC);
    theParams.setSortSpec(sort);
    results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThan(1));
    people = get(results);
    assertThat(people, hasSize(greaterThan(1)));
    for (int i = 1; i < people.size(); i++) {
        assertThat(people.get(i - 1).getAddressFirstRep().getState(), greaterThanOrEqualTo(people.get(i).getAddressFirstRep().getState()));
    }
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) Person(org.hl7.fhir.r4.model.Person) SortSpec(ca.uhn.fhir.rest.api.SortSpec) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 34 with Person

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

the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleForMatchOnPostalCode.

@Test
public void shouldReturnCollectionOfPeopleForMatchOnPostalCode() {
    StringAndListParam postalCode = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, postalCode);
    IBundleProvider people = search(theParams);
    assertThat(people, notNullValue());
    assertThat(people.size(), greaterThanOrEqualTo(1));
    List<Person> resultList = get(people);
    assertThat(resultList, not(empty()));
    assertThat(resultList.get(0).getAddressFirstRep().getPostalCode(), equalTo(POSTAL_CODE));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Person(org.hl7.fhir.r4.model.Person) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 35 with Person

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

the class BaseReferenceHandlingTranslatorTest method shouldReturnReferenceWithDisplayForProviderWithPerson.

@Test
public void shouldReturnReferenceWithDisplayForProviderWithPerson() {
    PersonName name = new PersonName();
    name.setGivenName(GIVEN_NAME);
    name.setFamilyName(FAMILY_NAME);
    Person person = new Person();
    person.setUuid(PERSON_UUID);
    person.addName(name);
    provider.setPerson(person);
    Reference reference = referenceHandlingTranslator.createPractitionerReference(provider);
    assertThat(reference, notNullValue());
    assertThat(reference.getDisplay(), equalTo(PROVIDER_DISPLAY));
}
Also used : PersonName(org.openmrs.PersonName) Reference(org.hl7.fhir.r4.model.Reference) Person(org.openmrs.Person) 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