Search in sources :

Example 6 with Description

use of ca.uhn.fhir.model.api.annotation.Description in project cqf-ruler by DBCG.

the class CodeSystemUpdateProvider method updateCodeSystems.

/**
 * Update existing {@link CodeSystem CodeSystems} with the codes in all
 * {@link ValueSet ValueSet} resources.
 * System level CodeSystem update operation
 *
 * @return FHIR {@link OperationOutcome OperationOutcome} detailing the success
 *         or failure of the
 *         operation
 */
@Description(shortDefinition = "$updateCodeSystems", value = "Update existing CodeSystems with the codes in all ValueSet resources. System level CodeSystem update operation", example = "$updateCodeSystems")
@Operation(name = "$updateCodeSystems", idempotent = true)
public OperationOutcome updateCodeSystems() {
    IBundleProvider valuesets = this.myValueSetDaoDSTU3.search(SearchParameterMap.newSynchronous());
    List<ValueSet> valueSets = valuesets.getAllResources().stream().map(x -> (ValueSet) x).collect(Collectors.toList());
    OperationOutcome outcome = this.performCodeSystemUpdate(valueSets);
    OperationOutcome response = new OperationOutcome();
    if (outcome.hasIssue()) {
        for (OperationOutcome.OperationOutcomeIssueComponent issue : outcome.getIssue()) {
            response.addIssue(issue);
        }
    }
    return response;
}
Also used : IIdType(org.hl7.fhir.instance.model.api.IIdType) IdParam(ca.uhn.fhir.rest.annotation.IdParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) Coding(org.hl7.fhir.dstu3.model.Coding) IdType(org.hl7.fhir.dstu3.model.IdType) Description(ca.uhn.fhir.model.api.annotation.Description) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Operation(ca.uhn.fhir.rest.annotation.Operation) Enumerations(org.hl7.fhir.dstu3.model.Enumerations) CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) Ids(org.opencds.cqf.ruler.utility.Ids) ArrayList(java.util.ArrayList) OperationProvider(org.opencds.cqf.ruler.api.OperationProvider) HashSet(java.util.HashSet) IFhirResourceDaoValueSet(ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet) Map(java.util.Map) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) SearchParameterMap(ca.uhn.fhir.jpa.searchparam.SearchParameterMap) Set(java.util.Set) UriParam(ca.uhn.fhir.rest.param.UriParam) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) IFhirResourceDaoCodeSystem(ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem) Collections(java.util.Collections) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IFhirResourceDaoValueSet(ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 7 with Description

use of ca.uhn.fhir.model.api.annotation.Description in project cqf-ruler by DBCG.

the class CacheValueSetsProvider method cacheValuesets.

/**
 * Using basic authentication this {@link Operation Operation} will update
 * any {@link ValueSet Valueset} listed given the {@link Endpoint Endpoint}
 * provided.
 * Any Valuesets that require expansion will be expanded.
 *
 * @param details    the {@link RequestDetails RequestDetails}
 * @param endpointId the {@link Endpoint Endpoint} id
 * @param valuesets  the {@link StringAndListParam list} of {@link ValueSet
 *                   Valueset} ids
 * @param userName   the userName
 * @param password   the password
 * @return the {@link OperationOutcome OperationOutcome} or the resulting
 *         {@link Bundle Bundle}
 */
@Description(shortDefinition = "$cache-valuesets", value = "Using basic authentication this Operation will update any Valueset listed given the Endpoint provided. Any Valuesets that require expansion will be expanded.", example = "Endpoint/example-id/$cache-valuesets?valuesets=valuesetId1&valuesets=valuesetId2&user=user&password=password")
@Operation(name = "cache-valuesets", idempotent = true, type = Endpoint.class)
public Resource cacheValuesets(RequestDetails details, @IdParam IdType endpointId, @OperationParam(name = "valuesets") StringAndListParam valuesets, @OperationParam(name = "user") String userName, @OperationParam(name = "pass") String password) {
    Endpoint endpoint = null;
    try {
        endpoint = this.endpointDao.read(endpointId);
        if (endpoint == null) {
            return createErrorOutcome("Could not find Endpoint/" + endpointId);
        }
    } catch (Exception e) {
        return createErrorOutcome("Could not find Endpoint/" + endpointId + "\n" + e);
    }
    IGenericClient client = Clients.forEndpoint(ourCtx, endpoint);
    if (userName != null || password != null) {
        if (userName == null) {
            return createErrorOutcome("Password was provided, but not a user name.");
        } else if (password == null) {
            return createErrorOutcome("User name was provided, but not a password.");
        }
        BasicAuthInterceptor basicAuth = new BasicAuthInterceptor(userName, password);
        client.registerInterceptor(basicAuth);
    // TODO - more advanced security like bearer tokens, etc...
    }
    try {
        Bundle bundleToPost = new Bundle();
        for (StringOrListParam params : valuesets.getValuesAsQueryTokens()) {
            for (StringParam valuesetId : params.getValuesAsQueryTokens()) {
                bundleToPost.addEntry().setRequest(new Bundle.BundleEntryRequestComponent().setMethod(Bundle.HTTPVerb.PUT).setUrl("ValueSet/" + valuesetId.getValue())).setResource(resolveValueSet(client, valuesetId.getValue()));
            }
        }
        return (Resource) systemDao.transaction(details, bundleToPost);
    } catch (Exception e) {
        return createErrorOutcome(e.getMessage());
    }
}
Also used : Endpoint(org.hl7.fhir.r4.model.Endpoint) BasicAuthInterceptor(ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 8 with Description

use of ca.uhn.fhir.model.api.annotation.Description in project cqf-ruler by DBCG.

the class ReportProvider method report.

/**
 * Implements the <a href=
 * "https://build.fhir.org/ig/HL7/davinci-ra/OperationDefinition-report.html">$report</a>
 * operation found in the
 * <a href="https://build.fhir.org/ig/HL7/davinci-ra/index.html">Da Vinci Risk
 * Adjustment IG</a>.
 *
 * @param requestDetails metadata about the current request being processed.
 *                       Generally auto-populated by the HAPI FHIR server
 *                       framework.
 * @param periodStart    the start of the clinical evaluation period
 * @param periodEnd      the end of the clinical evaluation period
 * @param subject        a Patient or Patient Group
 * @return a Parameters with Bundles of MeasureReports and evaluatedResource
 *         Resources
 */
@Description(shortDefinition = "$report", value = "Implements the <a href=\"https://build.fhir.org/ig/HL7/davinci-ra/OperationDefinition-report.html\">$report</a> operation found in the <a href=\"https://build.fhir.org/ig/HL7/davinci-ra/index.html\">Da Vinci Risk Adjustment IG</a>.")
@Operation(name = "$report", idempotent = true, type = MeasureReport.class)
public Parameters report(RequestDetails requestDetails, @OperationParam(name = "periodStart", min = 1, max = 1) String periodStart, @OperationParam(name = "periodEnd", min = 1, max = 1) String periodEnd, @OperationParam(name = "subject", min = 1, max = 1) String subject) throws FHIRException {
    validateParameters(periodStart, periodEnd, subject);
    Parameters result = newResource(Parameters.class, subject.replace("/", "-") + "-report");
    Date periodStartDate = Operations.resolveRequestDate(periodStart, true);
    Date periodEndDate = Operations.resolveRequestDate(periodEnd, false);
    Period period = new Period().setStart(periodStartDate).setEnd(periodEndDate);
    List<Patient> patients = getPatientListFromSubject(subject);
    (patients).forEach(patient -> {
        Parameters.ParametersParameterComponent patientParameter = patientReport(patient, period, requestDetails.getFhirServerBase());
        result.addParameter(patientParameter);
    });
    return result;
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) Period(org.hl7.fhir.r4.model.Period) Patient(org.hl7.fhir.r4.model.Patient) Date(java.util.Date) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 9 with Description

use of ca.uhn.fhir.model.api.annotation.Description in project cqf-ruler by DBCG.

the class MeasureEvaluateProvider method evaluateMeasure.

/**
 * Implements the <a href=
 * "https://www.hl7.org/fhir/operation-measure-evaluate-measure.html">$evaluate-measure</a>
 * operation found in the
 * <a href="http://www.hl7.org/fhir/clinicalreasoning-module.html">FHIR Clinical
 * Reasoning Module</a>. This implementation aims to be compatible with the CQF
 * IG.
 *
 * @param requestDetails The details (such as tenant) of this request. Usually
 *                       auto-populated HAPI.
 * @param theId          the Id of the Measure to evaluate
 * @param periodStart    The start of the reporting period
 * @param periodEnd      The end of the reporting period
 * @param reportType     The type of MeasureReport to generate
 * @param subject        the subject to use for the evaluation
 * @param practitioner   the practitioner to use for the evaluation
 * @param lastReceivedOn the date the results of this measure were last
 *                       received.
 * @param productLine    the productLine (e.g. Medicare, Medicaid, etc) to use
 *                       for the evaluation. This is a non-standard parameter.
 * @param additionalData the data bundle containing additional data
 * @return the calculated MeasureReport
 */
// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
@Description(shortDefinition = "$evaluate-measure", value = "Implements the <a href=\"https://www.hl7.org/fhir/operation-measure-evaluate-measure.html\">$evaluate-measure</a> operation found in the <a href=\"http://www.hl7.org/fhir/clinicalreasoning-module.html\">FHIR Clinical Reasoning Module</a>. This implementation aims to be compatible with the CQF IG.", example = "Measure/example/$evaluate-measure?subject=Patient/123&periodStart=2019&periodEnd=2020")
@Operation(name = "$evaluate-measure", idempotent = true, type = Measure.class)
public MeasureReport evaluateMeasure(RequestDetails requestDetails, @IdParam IdType theId, @OperationParam(name = "periodStart") String periodStart, @OperationParam(name = "periodEnd") String periodEnd, @OperationParam(name = "reportType") String reportType, @OperationParam(name = "subject") String subject, @OperationParam(name = "practitioner") String practitioner, @OperationParam(name = "lastReceivedOn") String lastReceivedOn, @OperationParam(name = "productLine") String productLine, @OperationParam(name = "additionalData") Bundle additionalData) {
    Measure measure = read(theId);
    TerminologyProvider terminologyProvider = this.jpaTerminologyProviderFactory.create(requestDetails);
    DataProvider dataProvider = this.jpaDataProviderFactory.create(requestDetails, terminologyProvider);
    LibraryContentProvider libraryContentProvider = this.libraryContentProviderFactory.create(requestDetails);
    FhirDal fhirDal = this.fhirDalFactory.create(requestDetails);
    org.opencds.cqf.cql.evaluator.measure.r4.R4MeasureProcessor measureProcessor = new org.opencds.cqf.cql.evaluator.measure.r4.R4MeasureProcessor(null, this.dataProviderFactory, null, null, null, terminologyProvider, libraryContentProvider, dataProvider, fhirDal, null, this.globalLibraryCache);
    MeasureReport report = measureProcessor.evaluateMeasure(measure.getUrl(), periodStart, periodEnd, reportType, subject, null, lastReceivedOn, null, null, null, additionalData);
    if (productLine != null) {
        Extension ext = new Extension();
        ext.setUrl("http://hl7.org/fhir/us/cqframework/cqfmeasures/StructureDefinition/cqfm-productLine");
        ext.setValue(new StringType(productLine));
        report.addExtension(ext);
    }
    return report;
}
Also used : LibraryContentProvider(org.opencds.cqf.cql.evaluator.cql2elm.content.LibraryContentProvider) StringType(org.hl7.fhir.r4.model.StringType) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) FhirDal(org.opencds.cqf.cql.evaluator.fhir.dal.FhirDal) DataProvider(org.opencds.cqf.cql.engine.data.DataProvider) Extension(org.hl7.fhir.r4.model.Extension) TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) Measure(org.hl7.fhir.r4.model.Measure) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 10 with Description

use of ca.uhn.fhir.model.api.annotation.Description in project cqf-ruler by DBCG.

the class CodeSystemUpdateProvider method updateCodeSystems.

/**
 * Update existing {@link CodeSystem CodeSystems} with the codes in the
 * specified {@link ValueSet ValueSet}.
 *
 * This is for development environment purposes to enable ValueSet expansion and
 * validation without complete CodeSystems.
 *
 * @param theId the id of the {@link ValueSet ValueSet}
 * @return FHIR {@link OperationOutcome OperationOutcome} detailing the success
 *         or failure of the
 *         operation
 */
@Description(shortDefinition = "$updateCodeSystems", value = "Update existing CodeSystems with the codes in the specified ValueSet This is for development environment purposes to enable ValueSet expansion and validation without complete CodeSystems.", example = "ValueSet/example-id/$updateCodeSystems")
@Operation(name = "$updateCodeSystems", idempotent = true, type = ValueSet.class)
public OperationOutcome updateCodeSystems(@IdParam IdType theId) {
    OperationOutcome response = new OperationOutcome();
    ValueSet vs = null;
    try {
        vs = this.myValueSetDaoR4.read(theId);
        if (vs == null) {
            return buildIssue(response, "error", "not-found", "Unable to find Resource: " + theId.getIdPart());
        }
    } catch (Exception e) {
        return buildIssue(response, "error", "not-found", "Unable to find Resource: " + theId.getIdPart() + "\n" + e);
    }
    return performCodeSystemUpdate(Collections.singletonList(vs));
}
Also used : OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) ValueSet(org.hl7.fhir.r4.model.ValueSet) IFhirResourceDaoValueSet(ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Aggregations

Description (ca.uhn.fhir.model.api.annotation.Description)17 Operation (ca.uhn.fhir.rest.annotation.Operation)15 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 IFhirResourceDaoValueSet (ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet)4 IdParam (ca.uhn.fhir.rest.annotation.IdParam)4 Collections (java.util.Collections)4 List (java.util.List)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 Parameters (org.hl7.fhir.r4.model.Parameters)4 IFhirResourceDaoCodeSystem (ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem)2 SearchParameterMap (ca.uhn.fhir.jpa.searchparam.SearchParameterMap)2 IdDt (ca.uhn.fhir.model.primitive.IdDt)2 OptionalParam (ca.uhn.fhir.rest.annotation.OptionalParam)2 Read (ca.uhn.fhir.rest.annotation.Read)2 RequiredParam (ca.uhn.fhir.rest.annotation.RequiredParam)2 Search (ca.uhn.fhir.rest.annotation.Search)2 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)2 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)2