use of es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter 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 es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter 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;
}
use of es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter in project elexis-server by elexis.
the class OrganizationResourceProvider method search.
@Search
public List<Organization> search(@OptionalParam(name = Organization.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
IQuery<IOrganization> query = coreModelService.getQuery(IOrganization.class);
if (name != null) {
QueryUtil.andContactNameCriterion(query, name);
}
if (theFtFilter != null) {
new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
}
// TODO default limit result number
List<IOrganization> organizations = query.execute();
List<Organization> _organizations = organizations.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
return _organizations;
}
use of es.fhir.rest.core.resources.util.IContactSearchFilterQueryAdapter in project elexis-server by elexis.
the class PatientResourceProvider method search.
@Search
public List<Patient> search(@OptionalParam(name = Patient.SP_IDENTIFIER) TokenParam identifier, @OptionalParam(name = Patient.SP_NAME) StringParam theName, @OptionalParam(name = Patient.SP_BIRTHDATE) DateParam theBirthDate, @OptionalParam(name = Patient.SP_ACTIVE) StringParam isActive, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter, @Sort SortSpec theSort, SummaryEnum theSummary) {
boolean includeDeleted = (isActive != null) ? Boolean.valueOf(isActive.getValue()) : false;
IQuery<IPatient> query = coreModelService.getQuery(IPatient.class, includeDeleted);
if (identifier != null && Objects.equals(IdentifierSystem.ELEXIS_PATNR.getSystem(), identifier.getSystem())) {
query.and(ModelPackage.Literals.ICONTACT__CODE, COMPARATOR.EQUALS, identifier.getValue());
}
if (theName != null) {
QueryUtil.andContactNameCriterion(query, theName);
}
if (theBirthDate != null) {
LocalDate localDate = Instant.ofEpochMilli(theBirthDate.getValue().getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
query.and(ModelPackage.Literals.IPERSON__DATE_OF_BIRTH, COMPARATOR.EQUALS, localDate);
}
if (theFtFilter != null) {
new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
}
if (theSort != null) {
String param = theSort.getParamName();
SortOrderEnum order = theSort.getOrder();
switch(param) {
case Patient.SP_FAMILY:
query.orderBy(ModelPackage.Literals.ICONTACT__DESCRIPTION1, QueryUtil.sortOrderEnumToLocal(order));
break;
case Patient.SP_GIVEN:
query.orderBy(ModelPackage.Literals.ICONTACT__DESCRIPTION2, QueryUtil.sortOrderEnumToLocal(order));
break;
default:
log.info("sortParamName [{}] not supported.", param);
break;
}
}
List<IPatient> patients = query.execute();
List<Patient> _patients = patients.parallelStream().map(org -> getTransformer().getFhirObject(org, theSummary, Collections.emptySet())).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
return _patients;
}
Aggregations