@Search() public List<Patient> searchByNames( @RequiredParam(name=Patient.SP_FAMILY) StringParam theFamilyName, @OptionalParam(name=Patient.SP_GIVEN) StringParam theGivenName ) { String familyName = theFamilyName.getValue(); String givenName = theGivenName != null ? theGivenName.getValue() : null; List<Patient> retVal = new ArrayList<Patient>(); // ...populate... return retVal; } //END SNIPPET: searchOptionalParam
@CoverageIgnore @Override StringParam newInstance() { return new StringParam(); }
@Override String doGetQueryParameterQualifier() { if (isExact()) { return Constants.PARAMQUALIFIER_STRING_EXACT; } else if (isContains()) { return Constants.PARAMQUALIFIER_STRING_CONTAINS; } else { return null; } }
/** * Returns a new param containing the same value as this param, but with the type copnverted * to {@link StringParam}. This is useful if you are using reference parameters and want to handle * chained parameters of different types in a single method. * <p> * See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_operations.html#dynamic_chains">Dynamic Chains</a> * in the HAPI FHIR documentation for an example of how to use this method. * </p> */ public StringParam toStringParam(FhirContext theContext) { StringParam retVal = new StringParam(); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext)); return retVal; }
@Override public String toString() { ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); builder.append("value", getValue()); if (myExact) { builder.append("exact", myExact); } if (myContains) { builder.append("contains", myContains); } if (getMissing() != null) { builder.append("missing", getMissing().booleanValue()); } return builder.toString(); }
} else if (theParameter instanceof StringParam) { StringParam id = (StringParam) theParameter; rawSearchTerm = id.getValue(); if (id.isContains()) { if (!myDaoConfig.isAllowContainsSearches()) { throw new MethodNotAllowedException(":contains modifier is disabled on this server"); if (myDaoConfig.isAllowContainsSearches()) { if (theParameter instanceof StringParam) { if (((StringParam) theParameter).isContains()) { likeExpression = createLeftAndRightMatchLikeExpression(likeExpression); } else { if (theParameter instanceof StringParam && ((StringParam) theParameter).isExact()) { Predicate exactCode = theBuilder.equal(theFrom.get("myValueExact"), rawSearchTerm); singleCode = theBuilder.and(singleCode, exactCode); boolean exactMatch = theParameter instanceof StringParam && ((StringParam) theParameter).isExact(); if (exactMatch) { String likeExpression; if (theParameter instanceof StringParam && ((StringParam) theParameter).isContains() && myDaoConfig.isAllowContainsSearches()) { likeExpression = createLeftAndRightMatchLikeExpression(normalizedString);
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof StringParam)) { return false; } StringParam other = (StringParam) obj; EqualsBuilder eb = new EqualsBuilder(); eb.append(myExact, other.myExact); eb.append(myContains, other.myContains); eb.append(myValue, other.myValue); eb.append(getMissing(), other.getMissing()); return eb.isEquals(); }
} else if (theParameter instanceof StringParam) { StringParam id = (StringParam) theParameter; rawSearchTerm = id.getValue(); if (id.isContains()) { if (!myDaoConfig.isAllowContainsSearches()) { throw new MethodNotAllowedException(":contains modifier is disabled on this server"); if (myDaoConfig.isAllowContainsSearches()) { if (theParameter instanceof StringParam) { if (((StringParam) theParameter).isContains()) { likeExpression = createLeftAndRightMatchLikeExpression(likeExpression); } else { if (theParameter instanceof StringParam && ((StringParam) theParameter).isExact()) { Predicate exactCode = theBuilder.equal(theFrom.get("myValueExact"), rawSearchTerm); singleCode = theBuilder.and(singleCode, exactCode); boolean exactMatch = theParameter instanceof StringParam && ((StringParam) theParameter).isExact(); if (exactMatch) { String likeExpression; if (theParameter instanceof StringParam && ((StringParam) theParameter).isContains() && myDaoConfig.isAllowContainsSearches()) { likeExpression = createLeftAndRightMatchLikeExpression(normalizedString);
@Override public String toString() { ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); builder.append("value", getValue()); if (myExact) { builder.append("exact", myExact); } if (myContains) { builder.append("contains", myContains); } if (getMissing() != null) { builder.append("missing", getMissing().booleanValue()); } return builder.toString(); }
/** * Returns a new param containing the same value as this param, but with the type copnverted * to {@link StringParam}. This is useful if you are using reference parameters and want to handle * chained parameters of different types in a single method. * <p> * See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_operations.html#dynamic_chains">Dynamic Chains</a> * in the HAPI FHIR documentation for an example of how to use this method. * </p> */ public StringParam toStringParam(FhirContext theContext) { StringParam retVal = new StringParam(); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext)); return retVal; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof StringParam)) { return false; } StringParam other = (StringParam) obj; EqualsBuilder eb = new EqualsBuilder(); eb.append(myExact, other.myExact); eb.append(myContains, other.myContains); eb.append(myValue, other.myValue); eb.append(getMissing(), other.getMissing()); return eb.isEquals(); }
private boolean matchIdsOr(List<? extends IQueryParameterType> theOrParams, IBaseResource theResource) { if (theResource == null) { return true; } return theOrParams.stream().anyMatch(param -> param instanceof StringParam && matchId(((StringParam)param).getValue(), theResource.getIdElement())); }
@Override public IQueryParameterType toQueryParameterType() { return new StringParam(getValueExact()); }
@Override String doGetQueryParameterQualifier() { if (isExact()) { return Constants.PARAMQUALIFIER_STRING_EXACT; } else if (isContains()) { return Constants.PARAMQUALIFIER_STRING_CONTAINS; } else { return null; } }
@Override public boolean matches(IQueryParameterType theParam) { if (!(theParam instanceof StringParam)) { return false; } StringParam string = (StringParam)theParam; String normalizedString = StringNormalizer.normalizeString(string.getValue()); return getValueNormalized().startsWith(normalizedString); } }
@SuppressWarnings("unchecked") @Override public List<IQueryParameterOr<?>> encode(FhirContext theContext, T theString) throws InternalErrorException { String retVal = doEncode(theString); if (isBlank(retVal)) { return Collections.emptyList(); } List<?> retValList = Collections.singletonList(ParameterUtil.singleton(new StringParam(retVal), null)); return (List<IQueryParameterOr<?>>) retValList; }
private void addPredicateLanguage(List<List<? extends IQueryParameterType>> theList) { for (List<? extends IQueryParameterType> nextList : theList) { Set<String> values = new HashSet<>(); for (IQueryParameterType next : nextList) { if (next instanceof StringParam) { String nextValue = ((StringParam) next).getValue(); if (isBlank(nextValue)) { continue; } values.add(nextValue); } else { throw new InternalErrorException("Lanugage parameter must be of type " + StringParam.class.getCanonicalName() + " - Got " + next.getClass().getCanonicalName()); } } if (values.isEmpty()) { continue; } Predicate predicate = myResourceTableRoot.get("myLanguage").as(String.class).in(values); myPredicates.add(predicate); } }
private StringAndListParam toStringAndList(List<StringType> theNarrative) { StringAndListParam retVal = new StringAndListParam(); if (theNarrative != null) { for (StringType next : theNarrative) { if (isNotBlank(next.getValue())) { retVal.addAnd(new StringOrListParam().addOr(new StringParam(next.getValue()))); } } } if (retVal.getValuesAsQueryTokens().isEmpty()) { return null; } return retVal; }
@Override public List<Long> everything(String theResourceName, SearchParameterMap theParams) { Long pid = null; if (theParams.get(IAnyResource.SP_RES_ID) != null) { String idParamValue; IQueryParameterType idParam = theParams.get(IAnyResource.SP_RES_ID).get(0).get(0); if (idParam instanceof TokenParam) { TokenParam idParm = (TokenParam) idParam; idParamValue = idParm.getValue(); } else { StringParam idParm = (StringParam) idParam; idParamValue = idParm.getValue(); } pid = myIdHelperService.translateForcedIdToPid(theResourceName, idParamValue); } Long referencingPid = pid; List<Long> retVal = doSearch(null, theParams, referencingPid); if (referencingPid != null) { retVal.add(referencingPid); } return retVal; }