Search in sources :

Example 96 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project openmrs-module-fhir2 by openmrs.

the class SearchParameterMapTest method shouldAddStringAndListParamIntoAnExistingMapUsingTheSameKeyValue.

@Test
public void shouldAddStringAndListParamIntoAnExistingMapUsingTheSameKeyValue() {
    StringAndListParam andListParam1 = new StringAndListParam();
    andListParam1.addAnd(new StringParam("John"));
    StringAndListParam andListParam2 = new StringAndListParam();
    andListParam2.addAnd(new StringParam("Joe"));
    searchParam.addParameter(NAME, andListParam1);
    searchParam.addParameter(NAME, andListParam2);
    assertThat(searchParam, notNullValue());
    assertThat(searchParam.getParameters(NAME), not(empty()));
    assertThat(searchParam.getParameters(NAME), hasSize(is(2)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) StringParam(ca.uhn.fhir.rest.param.StringParam) Test(org.junit.Test)

Example 97 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project elexis-server by elexis.

the class PersonResourceProvider method search.

@Search
public List<Person> search(@OptionalParam(name = Person.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
    IQuery<IPerson> query = modelService.getQuery(IPerson.class);
    if (name != null) {
        QueryUtil.andContactNameCriterion(query, name);
    }
    if (theFtFilter != null) {
        new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
    }
    List<IPerson> persons = query.execute();
    List<Person> _persons = persons.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    return _persons;
}
Also used : IdParam(ca.uhn.fhir.rest.annotation.IdParam) IFhirTransformerRegistry(ch.elexis.core.findings.util.fhir.IFhirTransformerRegistry) IFhirTransformer(ch.elexis.core.findings.util.fhir.IFhirTransformer) LoggerFactory(org.slf4j.LoggerFactory) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Update(ca.uhn.fhir.rest.annotation.Update) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IModelService(ch.elexis.core.services.IModelService) Component(org.osgi.service.component.annotations.Component) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Search(ca.uhn.fhir.rest.annotation.Search) IContactSearchFilterQueryAdapter(es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter) Delete(ca.uhn.fhir.rest.annotation.Delete) Activate(org.osgi.service.component.annotations.Activate) Person(org.hl7.fhir.r4.model.Person) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Read(ca.uhn.fhir.rest.annotation.Read) Logger(org.slf4j.Logger) Create(ca.uhn.fhir.rest.annotation.Create) IPerson(ch.elexis.core.model.IPerson) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) IQuery(ch.elexis.core.services.IQuery) List(java.util.List) ResourceParam(ca.uhn.fhir.rest.annotation.ResourceParam) QueryUtil(es.fhir.rest.core.resources.util.QueryUtil) StringParam(ca.uhn.fhir.rest.param.StringParam) Optional(java.util.Optional) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) Reference(org.osgi.service.component.annotations.Reference) IPerson(ch.elexis.core.model.IPerson) Optional(java.util.Optional) IContactSearchFilterQueryAdapter(es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter) Person(org.hl7.fhir.r4.model.Person) IPerson(ch.elexis.core.model.IPerson) Search(ca.uhn.fhir.rest.annotation.Search)

Example 98 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project elexis-server by elexis.

the class PractitionerResourceProvider method search.

@Search
public List<Practitioner> search(@OptionalParam(name = Practitioner.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
    IQuery<IMandator> query = coreModelService.getQuery(IMandator.class);
    if (name != null) {
        QueryUtil.andContactNameCriterion(query, name);
    }
    if (theFtFilter != null) {
        new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
    }
    List<IMandator> practitioners = query.execute();
    List<Practitioner> _practitioners = practitioners.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    return _practitioners;
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) IMandator(ch.elexis.core.model.IMandator) IFhirTransformerRegistry(ch.elexis.core.findings.util.fhir.IFhirTransformerRegistry) IFhirTransformer(ch.elexis.core.findings.util.fhir.IFhirTransformer) Collectors(java.util.stream.Collectors) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IModelService(ch.elexis.core.services.IModelService) IQuery(ch.elexis.core.services.IQuery) List(java.util.List) Component(org.osgi.service.component.annotations.Component) IUserService(ch.elexis.core.services.IUserService) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Search(ca.uhn.fhir.rest.annotation.Search) IContactSearchFilterQueryAdapter(es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter) QueryUtil(es.fhir.rest.core.resources.util.QueryUtil) StringParam(ca.uhn.fhir.rest.param.StringParam) Optional(java.util.Optional) Activate(org.osgi.service.component.annotations.Activate) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) Reference(org.osgi.service.component.annotations.Reference) Practitioner(org.hl7.fhir.r4.model.Practitioner) Optional(java.util.Optional) IMandator(ch.elexis.core.model.IMandator) IContactSearchFilterQueryAdapter(es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter) Search(ca.uhn.fhir.rest.annotation.Search)

Example 99 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method findLocationsByCountry_shouldReturnMatchingBundleOfLocations.

@Test
public void findLocationsByCountry_shouldReturnMatchingBundleOfLocations() {
    StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
    when(locationService.searchForLocations(isNull(), isNull(), argThat(Matchers.is(countryParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, countryParam, null, null, null, null, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getAddress().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) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 100 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method findLocationsByName_shouldReturnMatchingBundleOfLocations.

@Test
public void findLocationsByName_shouldReturnMatchingBundleOfLocations() {
    StringAndListParam nameParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
    when(locationService.searchForLocations(argThat(Matchers.is(nameParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(nameParam, null, null, null, null, null, null, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList.get(0).getName(), equalTo(LOCATION_NAME));
}
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) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.Test)

Aggregations

StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)264 StringParam (ca.uhn.fhir.rest.param.StringParam)243 Test (org.junit.Test)233 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)232 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)157 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)137 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)110 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)91 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)37 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)30 Practitioner (org.hl7.fhir.r4.model.Practitioner)26 Patient (org.hl7.fhir.r4.model.Patient)21 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 Test (org.junit.jupiter.api.Test)20 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)18 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)16 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)16 Location (org.hl7.fhir.r4.model.Location)14 Person (org.hl7.fhir.r4.model.Person)14 SortSpec (ca.uhn.fhir.rest.api.SortSpec)13