use of org.hl7.fhir.r4.model.Person 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;
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method createPerson_shouldCreateNewPerson.
@Test
public void createPerson_shouldCreateNewPerson() {
when(fhirPersonService.create(any(org.hl7.fhir.r4.model.Person.class))).thenReturn(person);
MethodOutcome result = resourceProvider.createPerson(Person30_40.convertPerson(person));
assertThat(result, notNullValue());
assertThat(result.getCreated(), is(true));
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(PERSON_UUID));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByPostalCode.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByPostalCode() {
StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(postalCodeParam)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, postalCodeParam, 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)));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldAddRelatedResourcesWhenIncluded.
@Test
public void searchForPeople_shouldAddRelatedResourcesWhenIncluded() {
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("Person:patient"));
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includes)))).thenReturn(new MockIBundleProvider<>(Arrays.asList(person, new Patient()), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.PERSON));
assertThat(resultList.get(1).fhirType(), is(FhirConstants.PATIENT));
assertThat(resultList.size(), equalTo(2));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByCountry.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByCountry() {
StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(countryParam)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, countryParam, 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)));
}
Aggregations