use of org.openmrs.module.fhir2.api.util.LastnResult in project openmrs-module-fhir2 by openmrs.
the class FhirObservationDaoImpl method getSearchResultUuids.
@Override
public List<String> getSearchResultUuids(@Nonnull SearchParameterMap theParams) {
if (!theParams.getParameters(FhirConstants.LASTN_OBSERVATION_SEARCH_HANDLER).isEmpty()) {
Criteria criteria = getSessionFactory().getCurrentSession().createCriteria(typeToken.getRawType());
setupSearchParams(criteria, theParams);
criteria.setProjection(Projections.projectionList().add(property("uuid")).add(property("concept")).add(property("obsDatetime")));
@SuppressWarnings("unchecked") List<LastnResult> results = ((List<Object[]>) criteria.list()).stream().map(objects -> {
Map<String, Object> attributes = new HashMap<>();
attributes.put("concept", objects[1]);
return new LastnResult(objects[0], objects[2], attributes);
}).collect(Collectors.toList());
return getLastnUuids(handleGrouping(results), getMaxParameter(theParams)).stream().distinct().collect(Collectors.toList());
}
if (!theParams.getParameters(FhirConstants.LASTN_ENCOUNTERS_SEARCH_HANDLER).isEmpty()) {
ReferenceAndListParam encountersReferences = new ReferenceAndListParam();
ReferenceOrListParam referenceOrListParam = new ReferenceOrListParam();
List<String> encounters = encounterDao.getSearchResultUuids(theParams);
encounters.forEach(encounter -> referenceOrListParam.addOr(new ReferenceParam().setValue(encounter)));
encountersReferences.addAnd(referenceOrListParam);
theParams.addParameter(FhirConstants.ENCOUNTER_REFERENCE_SEARCH_HANDLER, encountersReferences);
}
return super.getSearchResultUuids(theParams);
}
use of org.openmrs.module.fhir2.api.util.LastnResult in project openmrs-module-fhir2 by openmrs.
the class FhirEncounterDaoImpl method getSearchResultUuids.
@Override
public List<String> getSearchResultUuids(@Nonnull SearchParameterMap theParams) {
if (!theParams.getParameters(FhirConstants.LASTN_ENCOUNTERS_SEARCH_HANDLER).isEmpty()) {
Criteria criteria = getSessionFactory().getCurrentSession().createCriteria(typeToken.getRawType());
setupSearchParams(criteria, theParams);
criteria.setProjection(Projections.projectionList().add(property("uuid")).add(property("encounterDatetime")));
@SuppressWarnings("unchecked") List<LastnResult> results = ((List<Object[]>) criteria.list()).stream().map(LastnResult::new).collect(Collectors.toList());
return getTopNRankedUuids(results, getMaxParameter(theParams));
}
return super.getSearchResultUuids(theParams);
}
Aggregations