Search in sources :

Example 21 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleByLastUpdatedDateCreated.

@Test
public void shouldReturnCollectionOfRelatedPeopleByLastUpdatedDateCreated() {
    DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CREATED).setLowerBound(DATE_CREATED);
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(2));
    List<RelatedPerson> resultList = get(results);
    assertThat(resultList.size(), equalTo(2));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 22 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleByLastUpdatedDateChanged.

@Test
public void shouldReturnCollectionOfRelatedPeopleByLastUpdatedDateChanged() {
    DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CHANGED).setLowerBound(DATE_CHANGED);
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
    IBundleProvider results = search(theParams);
    List<RelatedPerson> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(equalTo(1)));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 23 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleForMatchOnCountry.

@Test
public void shouldReturnCollectionOfRelatedPeopleForMatchOnCountry() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, stringAndListParam);
    IBundleProvider relationships = search(theParams);
    assertThat(relationships, notNullValue());
    assertThat(relationships.size(), equalTo(1));
    List<RelatedPerson> relationList = get(relationships);
    assertThat(relationList, hasSize(equalTo(1)));
    assertThat(relationList.get(0).getAddressFirstRep().getCountry(), equalTo(COUNTRY));
}
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) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 24 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnGender.

@Test
public void shouldReturnEmptyCollectionForNoMatchOnGender() {
    TokenAndListParam tokenAndListParam = new TokenAndListParam().addAnd(new TokenOrListParam().add(WRONG_GENDER));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, tokenAndListParam);
    IBundleProvider relationships = search(theParams);
    assertThat(relationships, notNullValue());
    assertThat(relationships.size(), equalTo(0));
    List<RelatedPerson> relationList = get(relationships);
    assertThat(relationList, is(empty()));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 25 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleByUuid.

@Test
public void shouldReturnCollectionOfRelatedPeopleByUuid() {
    TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(RELATIONSHIP_UUID));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(1));
    List<RelatedPerson> resultList = get(results);
    assertThat(resultList, hasSize(equalTo(1)));
    assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(RELATIONSHIP_UUID));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)87 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)54 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)51 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)29 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)24 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)24 StringParam (ca.uhn.fhir.rest.param.StringParam)24 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)20 RelatedPerson (org.hl7.fhir.dstu3.model.RelatedPerson)17 Test (org.junit.jupiter.api.Test)17 Resource (org.hl7.fhir.r4.model.Resource)14 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)13 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)12 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)12 Patient (org.hl7.fhir.r4.model.Patient)12 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)11 Identifier (org.hl7.fhir.r4.model.Identifier)10 Reference (org.hl7.fhir.r4.model.Reference)9