Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cdr_cr_check/trigger_and_poll_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sys.exit(1)

if not project_api_read_token :
print("CDR-CR failed to run because READ_API_TOKEN was not set")
print("CDR-CR failed to run because READ_API_TOKEN (GITLAB_READ_API_TOKEN) was not set")
sys.exit(1)

# Enable logging
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compile_against_cdr-cr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
working-directory: ./.github/workflows/cdr_cr_check
env:
TRIGGER_TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
READ_API_TOKEN: ${{ secrets.GITLAB_READ_API_TOKEN }}
READ_API_TOKEN: ${{ secrets.GITLAB_READ_API_TOKEN_V2 }}
CLINICAL_REASONING_BRANCH: ${{ github.head_ref || github.ref_name }}
# When run via the manual run, this will be set. When run in a PR, it will be blank.
CDR_CR_BRANCH: ${{ inputs.cdr_cr_branch }}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.param.CompositeParam;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.InternalCodingDt;
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
Expand All @@ -16,11 +17,11 @@
import ca.uhn.fhir.rest.param.TokenParamModifier;
import ca.uhn.fhir.rest.param.UriParam;
import ca.uhn.fhir.util.ExtensionUtil;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -52,12 +53,14 @@ public abstract class BaseRetrieveProvider implements RetrieveProvider {
private final RetrieveSettings retrieveSettings;
private final TerminologyProvider terminologyProvider;
private final SearchParameterResolver resolver;
private final FhirContext fhirContext;

protected BaseRetrieveProvider(
final FhirContext fhirContext,
final TerminologyProvider terminologyProvider,
final RetrieveSettings retrieveSettings) {
requireNonNull(fhirContext, "fhirContext can not be null.");
this.fhirContext = fhirContext;
fhirVersion = fhirContext.getVersion().getVersion();
this.retrieveSettings = requireNonNull(retrieveSettings, "retrieveSettings can not be null");
this.terminologyProvider = requireNonNull(terminologyProvider, "terminologyProvider can not be null");
Expand Down Expand Up @@ -297,7 +300,7 @@ private String getValueSetFromCode(
}

public void populateTemplateSearchParams(
Map<String, List<IQueryParameterType>> searchParams, final String dataType, final String templateId) {
Multimap<String, List<IQueryParameterType>> searchParams, final String dataType, final String templateId) {
if (getRetrieveSettings().getProfileMode() != PROFILE_MODE.OFF
&& StringUtils.isNotBlank(templateId)
&& !templateId.startsWith("http://hl7.org/fhir/StructureDefinition/%s".formatted(dataType))) {
Expand All @@ -309,7 +312,7 @@ public void populateTemplateSearchParams(
}

public void populateContextSearchParams(
Map<String, List<IQueryParameterType>> searchParams,
Multimap<String, List<IQueryParameterType>> searchParams,
final String dataType,
final String context,
final String contextPath,
Expand All @@ -332,7 +335,7 @@ public void populateContextSearchParams(
}

public void populateTerminologySearchParams(
Map<String, List<IQueryParameterType>> searchParams,
Multimap<String, List<IQueryParameterType>> searchParams,
final String dataType,
final String codePath,
final Iterable<Code> codes,
Expand Down Expand Up @@ -390,13 +393,13 @@ protected boolean inModifierSupported(String valueSet, String resourceName, Stri
}

public void populateDateSearchParams(
Map<String, List<IQueryParameterType>> searchParams,
Multimap<String, List<IQueryParameterType>> searchParams,
final String dataType,
final String datePath,
final String dateParamName,
final String dateLowPath,
final String dateHighPath,
final Interval dateRange) {
if (datePath == null && dateHighPath == null && dateRange == null) {
if (dateParamName == null && dateHighPath == null && dateRange == null) {
return;
}

Expand All @@ -418,14 +421,14 @@ public void populateDateSearchParams(
+ dateRange.getStart().getClass().getSimpleName());
}

if (StringUtils.isNotBlank(datePath)) {
List<IQueryParameterType> dateRangeParam = new ArrayList<>();
DateParam dateParam = new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, start);
dateRangeParam.add(dateParam);
dateParam = new DateParam(ParamPrefixEnum.LESSTHAN_OR_EQUALS, end);
dateRangeParam.add(dateParam);
var sp = this.resolver.getSearchParameterDefinition(dataType, datePath);
searchParams.put(sp.getName(), dateRangeParam);
if (StringUtils.isNotBlank(dateParamName)) {
var sp = this.resolver.getSearchParameterDefinition(dataType, dateParamName);

// a date range is a search && condition - so we'll use a composite
DateParam gte = new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, start);
DateParam lte = new DateParam(ParamPrefixEnum.LESSTHAN_OR_EQUALS, end);

searchParams.put(sp.getName(), List.of(new CompositeParam<>(gte, lte)));
} else if (StringUtils.isNotBlank(dateLowPath)) {
List<IQueryParameterType> dateRangeParam = new ArrayList<>();
DateParam dateParam = new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ public FederatedDataProvider(ModelResolver modelResolver, List<RetrieveProvider>
this.retrieveProviders = retrieveProviders;
}

/**
*
* @param context - resource type
* @param contextPath -
* @param contextValue - id
* @param dataType - resource type
* @param templateId
* @param codePath
* @param codes
* @param valueSet
* @param datePath - the SP name to use
* @param dateLowPath - high path (period.start)
* @param dateHighPath - low path (period.end)
* @param dateRange - date range to search within
* @return
*/
@Override
public Iterable<Object> retrieve(
String context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.repository.IRepository;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
Expand All @@ -21,6 +22,18 @@
import org.opencds.cqf.fhir.utility.repository.ig.IgRepository;

public class RepositoryRetrieveProvider extends BaseRetrieveProvider {

private class SearchConfig {

/**
* Each element of each list is OR'd
* Each
*/
public Multimap<String, List<IQueryParameterType>> searchParams = HashMultimap.create();

public Predicate<IBaseResource> filter = x -> true;
}

private final IRepository repository;
private final FhirContext fhirContext;

Expand Down Expand Up @@ -126,20 +139,12 @@ private void configureDates(
switch (mode) {
case FILTER_IN_MEMORY:
case AUTO: // TODO: offload detection based on CapabilityStatement
if (datePath != null) {
throw new UnsupportedOperationException("in-memory dateFilters are not supported");
}
break;
case USE_SEARCH_PARAMETERS:
populateDateSearchParams(config.searchParams, dataType, datePath, dateLowPath, dateHighPath, dateRange);
break;
}
}

private class SearchConfig {
public Map<String, List<IQueryParameterType>> searchParams = new HashMap<>();
public Predicate<IBaseResource> filter = x -> true;
}

@Override
protected boolean inModifierSupported(String valueSet, String resourceName, String searchParamName) {
// The IN modifier is not currently supported by the ResourceMatcher used by the InMemoryRepository
Expand Down
Loading
Loading