diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java index 5bfc9fb26..58f980db6 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java @@ -710,18 +710,11 @@ protected Optional handleCodeableConcept(OpenmrsFhirCriteriaCo return handleAndListParamBySystem(criteriaContext.getCriteriaBuilder(), concepts, (system, tokens) -> { if (system.isEmpty()) { - criteriaContext.getCriteriaBuilder() - .literal(tokensToParams(tokens).map(NumberUtils::toInt).collect(Collectors.toList())); - return Optional - .of(criteriaContext - .getCriteriaBuilder().or( - criteriaContext.getCriteriaBuilder() - .in(conceptAlias.get("conceptId") - .in(criteriaContext.getCriteriaBuilder() - .literal(tokensToParams(tokens).map(NumberUtils::toInt) - .collect(Collectors.toList())))), - criteriaContext.getCriteriaBuilder().in(conceptAlias.get("uuid") - .in(criteriaContext.getCriteriaBuilder().literal(tokensToList(tokens)))))); + + Predicate inConceptId = criteriaContext.getCriteriaBuilder().in(conceptAlias.get("conceptId")).value(criteriaContext.getCriteriaBuilder().literal(tokensToParams(tokens).map(NumberUtils::toInt).collect(Collectors.toList()))); + Predicate inUuid = criteriaContext.getCriteriaBuilder().in(conceptAlias.get("uuid")).value(criteriaContext.getCriteriaBuilder().literal(tokensToList(tokens))); + + return Optional.of(criteriaContext.getCriteriaBuilder().or(inConceptId, inUuid)); } else { Join conceptMapAliasJoin = criteriaContext.addJoin(conceptAlias, "conceptMappings", conceptMapAlias); criteriaContext.addJoin(conceptMapAliasJoin, "conceptReferenceTerm", conceptReferenceTermAlias); @@ -1279,7 +1272,7 @@ protected OpenmrsFhirCriteriaContext createCriteriaContext(Class cq = (CriteriaQuery) cb.createQuery(rootType); @SuppressWarnings("unchecked") Root root = (Root) cq.from(rootType); - + return new OpenmrsFhirCriteriaContext<>(em, cb, cq, root); }