From a0f60c51fe0be9a31ca5581cc3a79edb61da608f Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 15 Apr 2024 14:50:24 +0300 Subject: [PATCH] fix some IllegalArguments in Allergies --- .../module/fhir2/api/dao/impl/BaseDao.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) 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); }