<commit_before>package org.cqframework.cql.data.fhir;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.IGenericClient;
import org.cqframework.cql.data.DataProvider;
import org.cqframework.cql.runtime.Concept;
import org.cqframework.cql.runtime.Interval;
import org.hl7.fhir.dstu3.model.Bundle;
import org.joda.time.Partial;

/**
 * Created by Bryn on 4/16/2016.
 */
public class FhirDataProvider implements DataProvider {
    private static FhirContext fhirContext = FhirContext.forDstu3();
    private IGenericClient fhirClient;

    private String endpoint;

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
        fhirClient = fhirContext.newRestfulGenericClient(endpoint);
    }

    public FhirDataProvider withEndpoint(String endpoint) {
        setEndpoint(endpoint);
        return this;
    }

    public Iterable<Object> retrieve(String context, String dataType, String templateId,
                                     String codePath, Iterable<Concept> codes, String datePath, String dateLowPath,
                                     String dateHighPath, Interval<Partial> dateRange) {

        // TODO: Apply filtering based on
        // profile (templateId)
        // codes
        // dateRange
        Bundle results = fhirClient.search().forResource(dataType).returnBundle(Bundle.class).execute();
        return new FhirBundleCursor(fhirClient, results);
    }
}<commit_msg>Rolling back change to make Context static<commit_after>package org.cqframework.cql.data.fhir;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.IGenericClient;
import org.cqframework.cql.data.DataProvider;
import org.cqframework.cql.runtime.Concept;
import org.cqframework.cql.runtime.Interval;
import org.hl7.fhir.dstu3.model.Bundle;
import org.joda.time.Partial;

/**
 * Created by Bryn on 4/16/2016.
 */
public class FhirDataProvider implements DataProvider {

    private String endpoint;
    public String getEndpoint() {
        return endpoint;
    }
    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
        fhirContext = FhirContext.forDstu3();
        fhirClient = fhirContext.newRestfulGenericClient(endpoint);
    }
    public FhirDataProvider withEndpoint(String endpoint) {
        setEndpoint(endpoint);
        return this;
    }

    private FhirContext fhirContext;
    private IGenericClient fhirClient;

    public Iterable<Object> retrieve(String context, String dataType, String templateId,
                                     String codePath, Iterable<Concept> codes, String datePath, String dateLowPath,
                                     String dateHighPath, Interval<Partial> dateRange) {

        // TODO: Apply filtering based on
        // profile (templateId)
        // codes
        // dateRange
        Bundle results = fhirClient.search().forResource(dataType).returnBundle(Bundle.class).execute();
        return new FhirBundleCursor(fhirClient, results);
    }
}
{'fraction_non_alphanumeric': 0.08830237862495927, 'fraction_numerical': 0.006516780710329097, 'mean_word_length': 2.9409499358151474, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6207250', 'n_tokens_mistral': 873, 'n_tokens_neox': 851, 'n_words': 192}