diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml
index 52e8c123781..573510eed59 100644
--- a/hapi-fhir-jpaserver-base/pom.xml
+++ b/hapi-fhir-jpaserver-base/pom.xml
@@ -238,7 +238,6 @@
org.hibernate
hibernate-search-orm
- 5.5.0.Final
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
index ee93f087537..36ab5668941 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
@@ -632,7 +632,7 @@ public abstract class BaseHapiFhirDao implements IDao {
};
}
- protected boolean isValidPid(IIdType theId) {
+ protected static boolean isValidPid(IIdType theId) {
if (theId == null || theId.getIdPart() == null) {
return false;
}
@@ -1186,10 +1186,14 @@ public abstract class BaseHapiFhirDao implements IDao {
}
protected Long translateForcedIdToPid(IIdType theId) {
+ return translateForcedIdToPid(theId, myEntityManager);
+ }
+
+ static Long translateForcedIdToPid(IIdType theId, EntityManager entityManager) {
if (isValidPid(theId)) {
return theId.getIdPartAsLong();
} else {
- TypedQuery q = myEntityManager.createNamedQuery("Q_GET_FORCED_ID", ForcedId.class);
+ TypedQuery q = entityManager.createNamedQuery("Q_GET_FORCED_ID", ForcedId.class);
q.setParameter("ID", theId.getIdPart());
try {
return q.getSingleResult().getResourcePid();
@@ -1356,7 +1360,7 @@ public abstract class BaseHapiFhirDao implements IDao {
}
}
-
+
if (theEntity.getId() == null) {
myEntityManager.persist(theEntity);
@@ -1426,6 +1430,7 @@ public abstract class BaseHapiFhirDao implements IDao {
myEntityManager.persist(next);
}
+ // Store resource links
for (ResourceLink next : resourceLinks) {
myEntityManager.remove(next);
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoPatientDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoPatientDstu2.java
index 0e0593867ec..ec78f8ac67d 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoPatientDstu2.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoPatientDstu2.java
@@ -33,18 +33,25 @@ import ca.uhn.fhir.model.primitive.UnsignedIntDt;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.param.DateRangeParam;
+import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringParam;
+import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
public class FhirResourceDaoPatientDstu2 extends FhirResourceDaoDstu2implements IFhirResourceDaoPatient {
- private IBundleProvider doEverythingOperation(IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
+ private IBundleProvider doEverythingOperation(IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
SearchParameterMap paramMap = new SearchParameterMap();
if (theCount != null) {
paramMap.setCount(theCount.getValue());
}
-
+ if (theContent != null) {
+ paramMap.add(Constants.PARAM_CONTENT, theContent);
+ }
+ if (theNarrative != null) {
+ paramMap.add(Constants.PARAM_TEXT, theNarrative);
+ }
paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
paramMap.setEverythingMode(theId != null ? EverythingModeEnum.PATIENT_INSTANCE : EverythingModeEnum.PATIENT_TYPE);
paramMap.setSort(theSort);
@@ -59,21 +66,21 @@ public class FhirResourceDaoPatientDstu2 extends FhirResourceDaoDstu2im
}
@Override
- public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
+ public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
// Notify interceptors
ActionRequestDetails requestDetails = new ActionRequestDetails(null, getResourceName());
notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_INSTANCE, requestDetails);
- return doEverythingOperation(theId, theCount, theLastUpdated, theSort);
+ return doEverythingOperation(theId, theCount, theLastUpdated, theSort, theContent, theNarrative);
}
@Override
- public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
+ public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
// Notify interceptors
ActionRequestDetails requestDetails = new ActionRequestDetails(null, getResourceName());
notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE, requestDetails);
- return doEverythingOperation(null, theCount, theLastUpdated, theSort);
+ return doEverythingOperation(null, theCount, theLastUpdated, theSort, theContent, theNarrative);
}
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSearchDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSearchDao.java
index 53707a0a4c8..ae760f56460 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSearchDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSearchDao.java
@@ -45,6 +45,8 @@ import org.springframework.transaction.annotation.Transactional;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.model.api.IQueryParameterType;
+import ca.uhn.fhir.model.dstu.resource.BaseResource;
+import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.Constants;
@@ -57,6 +59,10 @@ public class FhirSearchDao extends BaseHapiFhirDao implements ISe
@Transactional()
@Override
public List search(String theResourceName, SearchParameterMap theParams) {
+ return doSearch(theResourceName, theParams, null);
+ }
+
+ private List doSearch(String theResourceName, SearchParameterMap theParams, Long theReferencingPid) {
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
QueryBuilder qb = em
@@ -72,6 +78,10 @@ public class FhirSearchDao extends BaseHapiFhirDao implements ISe
List> textAndTerms = theParams.remove(Constants.PARAM_TEXT);
addTextSearch(qb, bool, textAndTerms, "myNarrativeText");
+ if (theReferencingPid != null) {
+ bool.must(qb.keyword().onField("myResourceLinks.myTargetResourcePid").matching(theReferencingPid).createQuery());
+ }
+
if (bool.isEmpty()) {
return null;
}
@@ -92,7 +102,10 @@ public class FhirSearchDao extends BaseHapiFhirDao implements ISe
ArrayList retVal = new ArrayList();
for (Object object : result) {
Object[] nextArray = (Object[]) object;
- retVal.add((Long)nextArray[0]);
+ Long next = (Long)nextArray[0];
+ if (next != null) {
+ retVal.add(next);
+ }
}
return retVal;
@@ -118,4 +131,23 @@ public class FhirSearchDao extends BaseHapiFhirDao implements ISe
}
}
+ @Override
+ public List everything(String theResourceName, SearchParameterMap theParams) {
+
+ Long pid = null;
+ if (theParams.get(BaseResource.SP_RES_ID) != null) {
+ StringParam idParm = (StringParam) theParams.get(BaseResource.SP_RES_ID).get(0).get(0);
+ pid = BaseHapiFhirDao.translateForcedIdToPid(new IdDt(idParm.getValue()), myEntityManager);
+ }
+
+ Long referencingPid = pid;
+ List retVal = doSearch(null, theParams, referencingPid);
+ if (referencingPid != null) {
+ retVal.add(referencingPid);
+ }
+ return retVal;
+ }
+
+
+
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFhirResourceDaoPatient.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFhirResourceDaoPatient.java
index efd8480cf51..a34d56d2251 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFhirResourceDaoPatient.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFhirResourceDaoPatient.java
@@ -28,12 +28,13 @@ import org.hl7.fhir.instance.model.api.IIdType;
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.param.DateRangeParam;
+import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.server.IBundleProvider;
public interface IFhirResourceDaoPatient extends IFhirResourceDao {
- IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdate, SortSpec theSort);
+ IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdate, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative);
- IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSortSpec);
+ IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSortSpec, StringAndListParam theContent, StringAndListParam theNarrative);
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchDao.java
index 9b52fa3c561..e8a66b6f8a7 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchDao.java
@@ -25,5 +25,7 @@ import java.util.List;
public interface ISearchDao {
List search(String theResourceName, SearchParameterMap theParams);
-
+
+ List everything(String theResourceName, SearchParameterMap theParams);
+
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
index 03c220ee000..baacd661955 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
@@ -117,7 +117,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
public class SearchBuilder {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilder.class);
-
+
private BaseHapiFhirDao> myCallingDao;
private FhirContext myContext;
private EntityManager myEntityManager;
@@ -135,7 +135,7 @@ public class SearchBuilder {
mySearchResultDao = theSearchResultDao;
myCallingDao = theDao;
}
-
+
private Set addPredicateComposite(RuntimeSearchParam theParamDef, Set thePids, List extends IQueryParameterType> theNextAnd) {
// TODO: fail if missing is set for a composite query
@@ -170,7 +170,7 @@ public class SearchBuilder {
return new HashSet(q.getResultList());
}
-
+
private Set addPredicateDate(String theParamName, Set thePids, List extends IQueryParameterType> theList) {
if (theList == null || theList.isEmpty()) {
return thePids;
@@ -225,7 +225,7 @@ public class SearchBuilder {
predicates.add(builder.equal(from.get("myResourceType"), myResourceName));
predicates.add(from.get("myId").in(thePids));
predicates.addAll(createLastUpdatedPredicates(theLastUpdated, builder, from));
-
+
cq.where(toArray(predicates));
TypedQuery q = myEntityManager.createQuery(cq);
@@ -274,8 +274,8 @@ public class SearchBuilder {
if (retVal.size() > 0) {
Predicate inPids = (from.get("myId").in(retVal));
predicates.add(inPids);
- }
-
+ }
+
predicates.add(builder.isNull(from.get("myDeleted")));
cq.where(toArray(predicates));
@@ -289,9 +289,8 @@ public class SearchBuilder {
return retVal;
}
-
- private boolean addPredicateMissingFalseIfPresent(CriteriaBuilder theBuilder, String theParamName, Root extends BaseResourceIndexedSearchParam> from, List codePredicates,
- IQueryParameterType nextOr) {
+
+ private boolean addPredicateMissingFalseIfPresent(CriteriaBuilder theBuilder, String theParamName, Root extends BaseResourceIndexedSearchParam> from, List codePredicates, IQueryParameterType nextOr) {
boolean missingFalse = false;
if (nextOr.getMissing() != null) {
if (nextOr.getMissing().booleanValue() == true) {
@@ -305,9 +304,7 @@ public class SearchBuilder {
return missingFalse;
}
-
- private boolean addPredicateMissingFalseIfPresentForResourceLink(CriteriaBuilder theBuilder, String theParamName, Root extends ResourceLink> from, List codePredicates,
- IQueryParameterType nextOr) {
+ private boolean addPredicateMissingFalseIfPresentForResourceLink(CriteriaBuilder theBuilder, String theParamName, Root extends ResourceLink> from, List codePredicates, IQueryParameterType nextOr) {
boolean missingFalse = false;
if (nextOr.getMissing() != null) {
if (nextOr.getMissing().booleanValue() == true) {
@@ -395,6 +392,7 @@ public class SearchBuilder {
TypedQuery q = myEntityManager.createQuery(cq);
return new HashSet(q.getResultList());
}
+
private Set addPredicateParamMissing(Set thePids, String joinName, String theParamName, Class extends BaseResourceIndexedSearchParam> theParamTable) {
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
CriteriaQuery cq = builder.createQuery(Long.class);
@@ -427,7 +425,6 @@ public class SearchBuilder {
return retVal;
}
-
private Set addPredicateParamMissingResourceLink(Set thePids, String joinName, String theParamName) {
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
CriteriaQuery cq = builder.createQuery(Long.class);
@@ -457,7 +454,7 @@ public class SearchBuilder {
HashSet retVal = new HashSet(resultList);
return retVal;
}
-
+
private Set addPredicateQuantity(String theParamName, Set thePids, List extends IQueryParameterType> theList) {
if (theList == null || theList.isEmpty()) {
return thePids;
@@ -572,8 +569,7 @@ public class SearchBuilder {
TypedQuery q = myEntityManager.createQuery(cq);
return new HashSet(q.getResultList());
}
-
-
+
private Set addPredicateReference(String theParamName, Set thePids, List extends IQueryParameterType> theList) {
assert theParamName.contains(".") == false;
@@ -766,6 +762,7 @@ public class SearchBuilder {
TypedQuery q = myEntityManager.createQuery(cq);
return new HashSet(q.getResultList());
}
+
private Set addPredicateTag(Set thePids, List> theList, String theParamName, DateRangeParam theLastUpdated) {
Set pids = thePids;
if (theList == null || theList.isEmpty()) {
@@ -849,7 +846,7 @@ public class SearchBuilder {
if (theLastUpdated != null) {
andPredicates.addAll(createLastUpdatedPredicates(theLastUpdated, builder, defJoin));
}
-
+
Predicate masterCodePredicate = builder.and(toArray(andPredicates));
if (pids.size() > 0) {
@@ -965,7 +962,6 @@ public class SearchBuilder {
return new HashSet(q.getResultList());
}
-
private Predicate createCompositeParamPart(CriteriaBuilder builder, Root from, RuntimeSearchParam left, IQueryParameterType leftValue) {
Predicate retVal = null;
switch (left.getParamType()) {
@@ -1072,8 +1068,7 @@ public class SearchBuilder {
}
}
- private Predicate createPredicateString(IQueryParameterType theParameter, String theParamName, CriteriaBuilder theBuilder,
- From theFrom) {
+ private Predicate createPredicateString(IQueryParameterType theParameter, String theParamName, CriteriaBuilder theBuilder, From theFrom) {
String rawSearchTerm;
if (theParameter instanceof TokenParam) {
TokenParam id = (TokenParam) theParameter;
@@ -1092,8 +1087,7 @@ public class SearchBuilder {
}
if (rawSearchTerm.length() > ResourceIndexedSearchParamString.MAX_LENGTH) {
- throw new InvalidRequestException("Parameter[" + theParamName + "] has length (" + rawSearchTerm.length() + ") that is longer than maximum allowed ("
- + ResourceIndexedSearchParamString.MAX_LENGTH + "): " + rawSearchTerm);
+ throw new InvalidRequestException("Parameter[" + theParamName + "] has length (" + rawSearchTerm.length() + ") that is longer than maximum allowed (" + ResourceIndexedSearchParamString.MAX_LENGTH + "): " + rawSearchTerm);
}
String likeExpression = BaseHapiFhirDao.normalizeString(rawSearchTerm);
@@ -1107,8 +1101,7 @@ public class SearchBuilder {
return singleCode;
}
- private Predicate createPredicateToken(IQueryParameterType theParameter, String theParamName, CriteriaBuilder theBuilder,
- From theFrom) {
+ private Predicate createPredicateToken(IQueryParameterType theParameter, String theParamName, CriteriaBuilder theBuilder, From theFrom) {
String code;
String system;
if (theParameter instanceof TokenParam) {
@@ -1128,12 +1121,10 @@ public class SearchBuilder {
}
if (system != null && system.length() > ResourceIndexedSearchParamToken.MAX_LENGTH) {
- throw new InvalidRequestException(
- "Parameter[" + theParamName + "] has system (" + system.length() + ") that is longer than maximum allowed (" + ResourceIndexedSearchParamToken.MAX_LENGTH + "): " + system);
+ throw new InvalidRequestException("Parameter[" + theParamName + "] has system (" + system.length() + ") that is longer than maximum allowed (" + ResourceIndexedSearchParamToken.MAX_LENGTH + "): " + system);
}
if (code != null && code.length() > ResourceIndexedSearchParamToken.MAX_LENGTH) {
- throw new InvalidRequestException(
- "Parameter[" + theParamName + "] has code (" + code.length() + ") that is longer than maximum allowed (" + ResourceIndexedSearchParamToken.MAX_LENGTH + "): " + code);
+ throw new InvalidRequestException("Parameter[" + theParamName + "] has code (" + code.length() + ") that is longer than maximum allowed (" + ResourceIndexedSearchParamToken.MAX_LENGTH + "): " + code);
}
ArrayList singleCodePredicates = (new ArrayList());
@@ -1169,11 +1160,11 @@ public class SearchBuilder {
List predicates = new ArrayList();
predicates.add(builder.equal(from.get("myResourceType"), myResourceName));
predicates.add(builder.isNull(from.get("myDeleted")));
-
+
if (theLastUpdated != null) {
predicates.addAll(createLastUpdatedPredicates(theLastUpdated, builder, from));
}
-
+
cq.where(toArray(predicates));
TypedQuery query = myEntityManager.createQuery(cq);
@@ -1281,9 +1272,9 @@ public class SearchBuilder {
Root from = cq.from(ResourceTable.class);
cq.select(from.get("myId").as(Long.class));
- List lastUpdatedPredicates = createLastUpdatedPredicates(theLastUpdated, builder, from);
+ List lastUpdatedPredicates = createLastUpdatedPredicates(theLastUpdated, builder, from);
lastUpdatedPredicates.add(0, from.get("myId").in(thePids));
-
+
cq.where(SearchBuilder.toArray(lastUpdatedPredicates));
TypedQuery query = myEntityManager.createQuery(cq);
List resultList = query.getResultList();
@@ -1325,10 +1316,11 @@ public class SearchBuilder {
theResourceListToPopulate.set(index, resource);
}
}
-
+
/**
* THIS SHOULD RETURN HASHSET and not jsut Set because we add to it later (so it can't be Collections.emptySet())
- * @param theLastUpdated
+ *
+ * @param theLastUpdated
*/
private HashSet loadReverseIncludes(Collection theMatches, Set theRevIncludes, boolean theReverseMode, EverythingModeEnum theEverythingModeEnum, DateRangeParam theLastUpdated) {
if (theMatches.size() == 0) {
@@ -1369,11 +1361,12 @@ public class SearchBuilder {
List results = q.getResultList();
for (ResourceLink resourceLink : results) {
if (theReverseMode) {
-// if (theEverythingModeEnum.isEncounter()) {
-// if (resourceLink.getSourcePath().equals("Encounter.subject") || resourceLink.getSourcePath().equals("Encounter.patient")) {
-// nextRoundOmit.add(resourceLink.getSourceResourcePid());
-// }
-// }
+ // if (theEverythingModeEnum.isEncounter()) {
+ // if (resourceLink.getSourcePath().equals("Encounter.subject") ||
+ // resourceLink.getSourcePath().equals("Encounter.patient")) {
+ // nextRoundOmit.add(resourceLink.getSourceResourcePid());
+ // }
+ // }
pidsToInclude.add(resourceLink.getSourceResourcePid());
} else {
pidsToInclude.add(resourceLink.getTargetResourcePid());
@@ -1443,10 +1436,9 @@ public class SearchBuilder {
return allAdded;
}
-
private List processSort(final SearchParameterMap theParams, Collection theLoadPids) {
final List pids;
-// Set loadPids = theLoadPids;
+ // Set loadPids = theLoadPids;
if (theParams.getSort() != null && isNotBlank(theParams.getSort().getParamName())) {
List orders = new ArrayList();
List predicates = new ArrayList();
@@ -1487,8 +1479,7 @@ public class SearchBuilder {
}
return pids;
}
-
-
+
public IBundleProvider search(final SearchParameterMap theParams) {
StopWatch w = new StopWatch();
final InstantDt now = InstantDt.withCurrentTime();
@@ -1501,28 +1492,41 @@ public class SearchBuilder {
Collection loadPids;
if (theParams.getEverythingMode() != null) {
- CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
- CriteriaQuery cq = builder.createTupleQuery();
- Root from = cq.from(ResourceTable.class);
- List predicates = new ArrayList();
+ Long pid = null;
if (theParams.get(BaseResource.SP_RES_ID) != null) {
StringParam idParm = (StringParam) theParams.get(BaseResource.SP_RES_ID).get(0).get(0);
- predicates.add(builder.equal(from.get("myId"), idParm.getValue()));
+ pid = BaseHapiFhirDao.translateForcedIdToPid(new IdDt(idParm.getValue()), myEntityManager);
}
- predicates.add(builder.equal(from.get("myResourceType"), myResourceName));
- predicates.add(builder.isNull(from.get("myDeleted")));
- cq.where(builder.and(SearchBuilder.toArray(predicates)));
- Join