docs: private void addPredicateReference(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) {
  		assert theParamName.contains(".") == false;
  
  		if (theList.get(0).getMissing() != null) {
  			addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing());
  			return;
  		}
  
  		Join<ResourceTable, ResourceLink> join = createJoin(JoinEnum.REFERENCE, theParamName);
  
  		List<IIdType> targetIds = new ArrayList<>();
  		List<String> targetQualifiedUrls = new ArrayList<>();
  
  		for (int orIdx = 0; orIdx < theList.size(); orIdx++) {
  			IQueryParameterType nextOr = theList.get(orIdx);
  
  			if (nextOr instanceof ReferenceParam) {
  				ReferenceParam ref = (ReferenceParam) nextOr;
  
  				if (isBlank(ref.getChain())) {
  
  					/*
  					 * Handle non-chained search, e.g. Patient?organization=Organization/123
  					 */
  
  					IIdType dt = new IdDt(ref.getBaseUrl(), ref.getResourceType(), ref.getIdPart(), null);
  
  					if (dt.hasBaseUrl()) {
  						if (myDaoConfig.getTreatBaseUrlsAsLocal().contains(dt.getBaseUrl())) {
  							dt = dt.toUnqualified();
  							targetIds.add(dt);
  						} else {
  							targetQualifiedUrls.add(dt.getValue());
  						}
  					} else {
  						targetIds.add(dt);
  					}
  
  				} else {
  
  					/*
  					 * Handle chained search, e.g. Patient?organization.name=Kwik-e-mart
  					 */
  
  					addPredicateReferenceWithChain(theResourceName, theParamName, theList, join, new ArrayList<>(), ref);
  					return;
  
  				}
  
  			} else {
  				throw new IllegalArgumentException("Invalid token type (expecting ReferenceParam): " + nextOr.getClass());
  			}
  
  		}
  
  		List<Predicate> codePredicates = new ArrayList<>();
  
  		// Resources by ID
  		List<Long> targetPids = myIdHelperService.translateForcedIdToPids(targetIds);
  		if (!targetPids.isEmpty()) {
  			ourLog.debug("Searching for resource link with target PIDs: {}", targetPids);
  			Predicate pathPredicate = createResourceLinkPathPredicate(theResourceName, theParamName, join);
  			Predicate pidPredicate = join.get("myTargetResourcePid").in(targetPids);
  			codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
  		}
  
  		// Resources by fully qualified URL
  		if (!targetQualifiedUrls.isEmpty()) {
  			ourLog.debug("Searching for resource link with target URLs: {}", targetQualifiedUrls);
  			Predicate pathPredicate = createResourceLinkPathPredicate(theResourceName, theParamName, join);
  			Predicate pidPredicate = join.get("myTargetResourceUrl").in(targetQualifiedUrls);
  			codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
  		}
  
  		if (codePredicates.size() > 0) {
  			myPredicates.add(myBuilder.or(toArray(codePredicates)));
  		} else {
  			// Add a predicate that will never match
  			Predicate pidPredicate = join.get("myTargetResourcePid").in(-1L);
  			myPredicates.clear();
  			myPredicates.add(pidPredicate);
  		}
  	}