Search in sources :

Example 16 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleForMatchOnState.

@Test
public void shouldReturnCollectionOfRelatedPeopleForMatchOnState() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_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().getState(), equalTo(STATE));
}
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 17 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnPersonName.

@Test
public void shouldReturnEmptyCollectionForNoMatchOnPersonName() {
    StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_FOUND_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, name);
    IBundleProvider relations = search(theParams);
    assertThat(relations, notNullValue());
    assertThat(relations.size(), equalTo(0));
    List<RelatedPerson> relationList = get(relations);
    assertThat(relationList, 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) 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 18 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByName.

@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByName() {
    SortSpec sort = new SortSpec();
    sort.setParamName(RelatedPerson.SP_NAME);
    sort.setOrder(SortOrderEnum.ASC);
    List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
    for (int i = 1; i < relationshipList.size(); i++) {
        assertThat(relationshipList.get(i - 1).getNameFirstRep().getFamily(), lessThanOrEqualTo(relationshipList.get(i).getNameFirstRep().getFamily()));
    }
    sort.setOrder(SortOrderEnum.DESC);
    relationshipList = getRelationListForSorting(sort);
    for (int i = 1; i < relationshipList.size(); i++) {
        assertThat(relationshipList.get(i - 1).getNameFirstRep().getFamily(), greaterThanOrEqualTo(relationshipList.get(i).getNameFirstRep().getFamily()));
    }
}
Also used : SortSpec(ca.uhn.fhir.rest.api.SortSpec) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 19 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByPostalCode.

@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByPostalCode() {
    SortSpec sort = new SortSpec();
    sort.setParamName(RelatedPerson.SP_ADDRESS_POSTALCODE);
    sort.setOrder(SortOrderEnum.ASC);
    List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
    for (int i = 1; i < relationshipList.size(); i++) {
        assertThat(relationshipList.get(i - 1).getAddressFirstRep().getPostalCode(), lessThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getPostalCode()));
    }
    sort.setOrder(SortOrderEnum.DESC);
    relationshipList = getRelationListForSorting(sort);
    for (int i = 1; i < relationshipList.size(); i++) {
        assertThat(relationshipList.get(i - 1).getAddressFirstRep().getPostalCode(), greaterThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getPostalCode()));
    }
}
Also used : SortSpec(ca.uhn.fhir.rest.api.SortSpec) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 20 with RelatedPerson

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleSortedByState.

@Test
public void shouldReturnCollectionOfRelatedPeopleSortedByState() {
    SortSpec sort = new SortSpec();
    sort.setParamName(RelatedPerson.SP_ADDRESS_STATE);
    sort.setOrder(SortOrderEnum.ASC);
    List<RelatedPerson> relationshipList = getRelationListForSorting(sort);
    for (int i = 1; i < relationshipList.size(); i++) {
        assertThat(relationshipList.get(i - 1).getAddressFirstRep().getState(), lessThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getState()));
    }
    sort.setOrder(SortOrderEnum.DESC);
    relationshipList = getRelationListForSorting(sort);
    for (int i = 1; i < relationshipList.size(); i++) {
        assertThat(relationshipList.get(i - 1).getAddressFirstRep().getState(), greaterThanOrEqualTo(relationshipList.get(i).getAddressFirstRep().getState()));
    }
}
Also used : SortSpec(ca.uhn.fhir.rest.api.SortSpec) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) 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