Implemented changes/fixes and associated unit tests for following _filter operators for strings:
- eq - ne - co - sw - ew
This commit is contained in:
parent
b27af398b4
commit
09daf7aacc
|
@ -545,16 +545,20 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
List<Long> targetPids = myIdHelperService.translateForcedIdToPids(targetIds, theRequest);
|
List<Long> targetPids = myIdHelperService.translateForcedIdToPids(targetIds, theRequest);
|
||||||
if (!targetPids.isEmpty()) {
|
if (!targetPids.isEmpty()) {
|
||||||
ourLog.debug("Searching for resource link with target PIDs: {}", targetPids);
|
ourLog.debug("Searching for resource link with target PIDs: {}", targetPids);
|
||||||
Predicate pathPredicate = createResourceLinkPathPredicate(theResourceName, theParamName, join);
|
Predicate pathPredicate = ((operation == null) || (operation == SearchFilterParser.CompareOperation.eq)) ? createResourceLinkPathPredicate(theResourceName, theParamName, join)
|
||||||
Predicate pidPredicate = join.get("myTargetResourcePid").in(targetPids);
|
: createResourceLinkPathPredicate(theResourceName, theParamName, join).not();
|
||||||
|
Predicate pidPredicate = ((operation == null) || (operation == SearchFilterParser.CompareOperation.eq)) ? join.get("myTargetResourcePid").in(targetPids)
|
||||||
|
: join.get("myTargetResourcePid").in(targetPids).not();
|
||||||
codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
|
codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources by fully qualified URL
|
// Resources by fully qualified URL
|
||||||
if (!targetQualifiedUrls.isEmpty()) {
|
if (!targetQualifiedUrls.isEmpty()) {
|
||||||
ourLog.debug("Searching for resource link with target URLs: {}", targetQualifiedUrls);
|
ourLog.debug("Searching for resource link with target URLs: {}", targetQualifiedUrls);
|
||||||
Predicate pathPredicate = createResourceLinkPathPredicate(theResourceName, theParamName, join);
|
Predicate pathPredicate = ((operation == null) || (operation == SearchFilterParser.CompareOperation.eq)) ? createResourceLinkPathPredicate(theResourceName, theParamName, join)
|
||||||
Predicate pidPredicate = join.get("myTargetResourceUrl").in(targetQualifiedUrls);
|
: createResourceLinkPathPredicate(theResourceName, theParamName, join).not();
|
||||||
|
Predicate pidPredicate = ((operation == null) || (operation == SearchFilterParser.CompareOperation.eq)) ? join.get("myTargetResourceUrl").in(targetQualifiedUrls)
|
||||||
|
: join.get("myTargetResourceUrl").in(targetQualifiedUrls).not();
|
||||||
codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
|
codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1717,35 +1721,39 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
|
|
||||||
boolean exactMatch = theParameter instanceof StringParam && ((StringParam) theParameter).isExact();
|
boolean exactMatch = theParameter instanceof StringParam && ((StringParam) theParameter).isExact();
|
||||||
if (exactMatch) {
|
if (exactMatch) {
|
||||||
|
|
||||||
// Exact match
|
// Exact match
|
||||||
|
|
||||||
Long hash = ResourceIndexedSearchParamString.calculateHashExact(theResourceName, theParamName, rawSearchTerm);
|
Long hash = ResourceIndexedSearchParamString.calculateHashExact(theResourceName, theParamName, rawSearchTerm);
|
||||||
return theBuilder.equal(theFrom.get("myHashExact").as(Long.class), hash);
|
return theBuilder.equal(theFrom.get("myHashExact").as(Long.class), hash);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Normalized Match
|
// Normalized Match
|
||||||
|
|
||||||
String normalizedString = StringNormalizer.normalizeString(rawSearchTerm);
|
String normalizedString = StringNormalizer.normalizeString(rawSearchTerm);
|
||||||
String likeExpression;
|
String likeExpression;
|
||||||
if (theParameter instanceof StringParam &&
|
if ((theParameter instanceof StringParam) &&
|
||||||
((StringParam) theParameter).isContains() &&
|
(((((StringParam) theParameter).isContains()) &&
|
||||||
myDaoConfig.isAllowContainsSearches()) {
|
(myCallingDao.getConfig().isAllowContainsSearches())) ||
|
||||||
|
(operation == SearchFilterParser.CompareOperation.co))) {
|
||||||
likeExpression = createLeftAndRightMatchLikeExpression(normalizedString);
|
likeExpression = createLeftAndRightMatchLikeExpression(normalizedString);
|
||||||
|
} else if ((operation != SearchFilterParser.CompareOperation.ne) &&
|
||||||
|
(operation != SearchFilterParser.CompareOperation.gt) &&
|
||||||
|
(operation != SearchFilterParser.CompareOperation.lt) &&
|
||||||
|
(operation != SearchFilterParser.CompareOperation.ge) &&
|
||||||
|
(operation != SearchFilterParser.CompareOperation.le)) {
|
||||||
|
if (operation == SearchFilterParser.CompareOperation.ew) {
|
||||||
|
likeExpression = createRightMatchLikeExpression(normalizedString);
|
||||||
|
} else {
|
||||||
|
likeExpression = createLeftMatchLikeExpression(normalizedString);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
likeExpression = createLeftMatchLikeExpression(normalizedString);
|
likeExpression = normalizedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate predicate;
|
Predicate predicate;
|
||||||
if ((operation == null) ||
|
if ((operation == null) ||
|
||||||
(operation == SearchFilterParser.CompareOperation.sw) ||
|
(operation == SearchFilterParser.CompareOperation.sw) ||
|
||||||
(operation == SearchFilterParser.CompareOperation.ew)) {
|
(operation == SearchFilterParser.CompareOperation.ew) ||
|
||||||
|
(operation == SearchFilterParser.CompareOperation.co)) {
|
||||||
Long hash = ResourceIndexedSearchParamString.calculateHashNormalized(myDaoConfig.getModelConfig(), theResourceName, theParamName, normalizedString);
|
|
||||||
Predicate hashCode = theBuilder.equal(theFrom.get("myHashNormalizedPrefix").as(Long.class), hash);
|
|
||||||
Predicate singleCode = theBuilder.like(theFrom.get("myValueNormalized").as(String.class), likeExpression);
|
Predicate singleCode = theBuilder.like(theFrom.get("myValueNormalized").as(String.class), likeExpression);
|
||||||
predicate = theBuilder.and(hashCode, singleCode);
|
predicate = combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, theFrom, singleCode);
|
||||||
} else if (operation == SearchFilterParser.CompareOperation.eq) {
|
} else if (operation == SearchFilterParser.CompareOperation.eq) {
|
||||||
Long hash = ResourceIndexedSearchParamString.calculateHashNormalized(myDaoConfig.getModelConfig(), theResourceName, theParamName, normalizedString);
|
Long hash = ResourceIndexedSearchParamString.calculateHashNormalized(myDaoConfig.getModelConfig(), theResourceName, theParamName, normalizedString);
|
||||||
Predicate hashCode = theBuilder.equal(theFrom.get("myHashNormalizedPrefix").as(Long.class), hash);
|
Predicate hashCode = theBuilder.equal(theFrom.get("myHashNormalizedPrefix").as(Long.class), hash);
|
||||||
|
@ -1857,11 +1865,9 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
codes.addAll(myTerminologySvc.expandValueSet(code));
|
codes.addAll(myTerminologySvc.expandValueSet(code));
|
||||||
} else if (modifier == TokenParamModifier.ABOVE) {
|
} else if (modifier == TokenParamModifier.ABOVE) {
|
||||||
system = determineSystemIfMissing(theParamName, code, system);
|
system = determineSystemIfMissing(theParamName, code, system);
|
||||||
validateHaveSystemAndCodeForToken(theParamName, code, system);
|
|
||||||
codes.addAll(myTerminologySvc.findCodesAbove(system, code));
|
codes.addAll(myTerminologySvc.findCodesAbove(system, code));
|
||||||
} else if (modifier == TokenParamModifier.BELOW) {
|
} else if (modifier == TokenParamModifier.BELOW) {
|
||||||
system = determineSystemIfMissing(theParamName, code, system);
|
system = determineSystemIfMissing(theParamName, code, system);
|
||||||
validateHaveSystemAndCodeForToken(theParamName, code, system);
|
|
||||||
codes.addAll(myTerminologySvc.findCodesBelow(system, code));
|
codes.addAll(myTerminologySvc.findCodesBelow(system, code));
|
||||||
} else {
|
} else {
|
||||||
codes.add(new VersionIndependentConcept(system, code));
|
codes.add(new VersionIndependentConcept(system, code));
|
||||||
|
@ -1904,19 +1910,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateHaveSystemAndCodeForToken(String theParamName, String theCode, String theSystem) {
|
|
||||||
String systemDesc = defaultIfBlank(theSystem, "(missing)");
|
|
||||||
String codeDesc = defaultIfBlank(theCode, "(missing)");
|
|
||||||
if (isBlank(theCode)) {
|
|
||||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, "invalidCodeMissingSystem", theParamName, systemDesc, codeDesc);
|
|
||||||
throw new InvalidRequestException(msg);
|
|
||||||
}
|
|
||||||
if (isBlank(theSystem)) {
|
|
||||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, "invalidCodeMissingCode", theParamName, systemDesc, codeDesc);
|
|
||||||
throw new InvalidRequestException(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Predicate addPredicateToken(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From<?, ResourceIndexedSearchParamToken> theFrom, List<VersionIndependentConcept> theTokens, TokenParamModifier theModifier, TokenModeEnum theTokenMode) {
|
private Predicate addPredicateToken(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From<?, ResourceIndexedSearchParamToken> theFrom, List<VersionIndependentConcept> theTokens, TokenParamModifier theModifier, TokenModeEnum theTokenMode) {
|
||||||
if (myDontUseHashesForSearch) {
|
if (myDontUseHashesForSearch) {
|
||||||
final Path<String> systemExpression = theFrom.get("mySystem");
|
final Path<String> systemExpression = theFrom.get("mySystem");
|
||||||
|
@ -2071,7 +2064,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
outerQuery.multiselect(myBuilder.countDistinct(myResourceTableRoot));
|
outerQuery.multiselect(myBuilder.countDistinct(myResourceTableRoot));
|
||||||
} else {
|
} else {
|
||||||
outerQuery.multiselect(myResourceTableRoot.get("myId").as(Long.class));
|
outerQuery.multiselect(myResourceTableRoot.get("myId").as(Long.class));
|
||||||
outerQuery.distinct(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3141,8 +3133,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
|
|
||||||
private final SearchRuntimeDetails mySearchRuntimeDetails;
|
private final SearchRuntimeDetails mySearchRuntimeDetails;
|
||||||
private final RequestDetails myRequest;
|
private final RequestDetails myRequest;
|
||||||
private final boolean myHaveRawSqlHooks;
|
|
||||||
private final boolean myHavePerftraceFoundIdHook;
|
|
||||||
private boolean myFirst = true;
|
private boolean myFirst = true;
|
||||||
private IncludesIterator myIncludesIterator;
|
private IncludesIterator myIncludesIterator;
|
||||||
private Long myNext;
|
private Long myNext;
|
||||||
|
@ -3161,16 +3151,13 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
if (myParams.getEverythingMode() != null) {
|
if (myParams.getEverythingMode() != null) {
|
||||||
myStillNeedToFetchIncludes = true;
|
myStillNeedToFetchIncludes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
myHavePerftraceFoundIdHook =JpaInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_SEARCH_FOUND_ID, myInterceptorBroadcaster, myRequest);
|
|
||||||
myHaveRawSqlHooks = JpaInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_RAW_SQL, myInterceptorBroadcaster, myRequest);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchNext() {
|
private void fetchNext() {
|
||||||
|
|
||||||
|
boolean haveRawSqlHooks = JpaInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_RAW_SQL, myInterceptorBroadcaster, myRequest);
|
||||||
try {
|
try {
|
||||||
if (myHaveRawSqlHooks) {
|
if (haveRawSqlHooks) {
|
||||||
CurrentThreadCaptureQueriesListener.startCapturing();
|
CurrentThreadCaptureQueriesListener.startCapturing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3211,13 +3198,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
if (myNext == null) {
|
if (myNext == null) {
|
||||||
while (myResultsIterator.hasNext()) {
|
while (myResultsIterator.hasNext()) {
|
||||||
Long next = myResultsIterator.next();
|
Long next = myResultsIterator.next();
|
||||||
if (myHavePerftraceFoundIdHook) {
|
|
||||||
HookParams params = new HookParams()
|
|
||||||
.add(Integer.class, System.identityHashCode(this))
|
|
||||||
.add(Object.class, next);
|
|
||||||
JpaInterceptorBroadcaster.doCallHooks(myInterceptorBroadcaster, myRequest, Pointcut.JPA_PERFTRACE_SEARCH_FOUND_ID, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
if (myPidSet.add(next)) {
|
if (myPidSet.add(next)) {
|
||||||
myNext = next;
|
myNext = next;
|
||||||
|
@ -3256,7 +3236,7 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
mySearchRuntimeDetails.setFoundMatchesCount(myPidSet.size());
|
mySearchRuntimeDetails.setFoundMatchesCount(myPidSet.size());
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (myHaveRawSqlHooks) {
|
if (haveRawSqlHooks) {
|
||||||
SqlQueryList capturedQueries = CurrentThreadCaptureQueriesListener.getCurrentQueueAndStopCapturing();
|
SqlQueryList capturedQueries = CurrentThreadCaptureQueriesListener.getCurrentQueueAndStopCapturing();
|
||||||
HookParams params = new HookParams()
|
HookParams params = new HookParams()
|
||||||
.add(RequestDetails.class, myRequest)
|
.add(RequestDetails.class, myRequest)
|
||||||
|
|
|
@ -204,6 +204,210 @@ public class FhirResourceDaoR4FilterTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStringComparatorNe() {
|
||||||
|
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.addName().setFamily("Smith").addGiven("John");
|
||||||
|
p.setActive(true);
|
||||||
|
String id1 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
p = new Patient();
|
||||||
|
p.addName().setFamily("Jones").addGiven("Frank");
|
||||||
|
p.setActive(false);
|
||||||
|
String id2 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
SearchParameterMap map;
|
||||||
|
List<String> found;
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("family ne smith"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id2));
|
||||||
|
assertThat(found, containsInAnyOrder(Matchers.not(id1)));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("family ne jones"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id1));
|
||||||
|
assertThat(found, containsInAnyOrder(Matchers.not(id2)));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("given ne john"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id2));
|
||||||
|
assertThat(found, containsInAnyOrder(Matchers.not(id1)));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("given ne frank"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id1));
|
||||||
|
assertThat(found, containsInAnyOrder(Matchers.not(id2)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReferenceComparatorNe() {
|
||||||
|
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.addName().setFamily("Smith").addGiven("John");
|
||||||
|
p.setActive(true);
|
||||||
|
IIdType ptId = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
p = new Patient();
|
||||||
|
p.addName().setFamily("Smith").addGiven("John2");
|
||||||
|
p.setActive(true);
|
||||||
|
IIdType ptId2 = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
CarePlan cp = new CarePlan();
|
||||||
|
cp.getSubject().setReference(ptId.getValue());
|
||||||
|
String cpId = myCarePlanDao.create(cp).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
cp = new CarePlan();
|
||||||
|
cp.addActivity().getDetail().addPerformer().setReference(ptId2.getValue());
|
||||||
|
String cpId2 = myCarePlanDao.create(cp).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
SearchParameterMap map;
|
||||||
|
List<String> found;
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("subject ne " + ptId.getValue()));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myCarePlanDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(cpId2));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("subject ne " + ptId.getIdPart()));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myCarePlanDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(cpId2));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("(subject ne " + ptId.getIdPart() + ") and (performer ne " + ptId2.getValue() + ")"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myCarePlanDao.search(map));
|
||||||
|
assertThat(found, Matchers.empty());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStringComparatorCo() {
|
||||||
|
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.addName().setFamily("Smith").addGiven("John");
|
||||||
|
p.setActive(true);
|
||||||
|
String id1 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
p = new Patient();
|
||||||
|
p.addName().setFamily("Jones").addGiven("Frank");
|
||||||
|
p.setActive(false);
|
||||||
|
String id2 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
SearchParameterMap map;
|
||||||
|
List<String> found;
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("name co smi"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id1));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("name co smith"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id1));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("given co frank"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id2));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("family co jones"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStringComparatorSw() {
|
||||||
|
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.addName().setFamily("Smith").addGiven("John");
|
||||||
|
p.setActive(true);
|
||||||
|
String id1 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
p = new Patient();
|
||||||
|
p.addName().setFamily("Jones").addGiven("Frank");
|
||||||
|
p.setActive(false);
|
||||||
|
String id2 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
SearchParameterMap map;
|
||||||
|
List<String> found;
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("name sw smi"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id1));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("name sw mi"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, Matchers.empty());
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("given sw fr"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStringComparatorEw() {
|
||||||
|
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.addName().setFamily("Smith").addGiven("John");
|
||||||
|
p.setActive(true);
|
||||||
|
String id1 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
p = new Patient();
|
||||||
|
p.addName().setFamily("Jones").addGiven("Frank");
|
||||||
|
p.setActive(false);
|
||||||
|
String id2 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
SearchParameterMap map;
|
||||||
|
List<String> found;
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("family ew ith"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id1));
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("name ew it"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, Matchers.empty());
|
||||||
|
|
||||||
|
map = new SearchParameterMap();
|
||||||
|
map.setLoadSynchronous(true);
|
||||||
|
map.add(Constants.PARAM_FILTER, new StringParam("given ew nk"));
|
||||||
|
found = toUnqualifiedVersionlessIdValues(myPatientDao.search(map));
|
||||||
|
assertThat(found, containsInAnyOrder(id2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClassClearContext() {
|
public static void afterClassClearContext() {
|
||||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
|
|
Loading…
Reference in New Issue