SearchParameterResolver { public Pair<String, IQueryParameterType> createSearchParameter(String context, String dataType, String path, String value) { RuntimeSearchParam searchParam = this.getSearchParameterDefinition(dataType, path); if (searchParam == null) { return null; } String name = searchParam.getName(); switch (searchParam.getParamType()) { case TOKEN: return Pair.of(name, new TokenParam(value)); case REFERENCE: return Pair.of(name, new ReferenceParam(context, null, value)); case QUANTITY: return Pair.of(name, new QuantityParam(value)); case STRING: return Pair.of(name, new StringParam(value)); case NUMBER: return Pair.of(name, new NumberParam(value)); case URI: return Pair.of(name, new UriParam(value)); case DATE: case HAS: case COMPOSITE: case SPECIAL: } return null; } SearchParameterResolver(FhirContext context); RuntimeSearchParam getSearchParameterDefinition(String dataType, String path); RuntimeSearchParam getSearchParameterDefinition(String dataType, String path, RestSearchParameterTypeEnum paramType); Pair<String, IQueryParameterType> createSearchParameter(String context, String dataType, String path, String value);  }
@Test void testR4ReferenceParameter() { FhirContext context = FhirContext.forR4(); SearchParameterResolver resolver = new SearchParameterResolver(context); Pair<String, IQueryParameterType> actual = resolver.createSearchParameter("Patient", "Observation", "subject", "123"); assertEquals("Patient/123", actual.getRight().getValueAsQueryToken(context)); }
@Test void testR4TokenParameter() { FhirContext context = FhirContext.forR4(); SearchParameterResolver resolver = new SearchParameterResolver(context); Pair<String, IQueryParameterType> actual = resolver.createSearchParameter("Patient", "Observation", "code", "123"); assertEquals("123", actual.getRight().getValueAsQueryToken(context)); }