Search in sources :

Example 16 with Description

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

the class CollectDataProvider method collectData.

/**
 * Implements the <a href="http://hl7.org/fhir/DSTU3/measure-operation-collect-data.html">$collect-data</a>
 * operation found in the
 * <a href="http://hl7.org/fhir/DSTU3/clinicalreasoning-module.html">FHIR Clinical Reasoning Module</a>.
 *
 * <p>Returns a set of parameters with the generated MeasureReport and the
 * resources that were used during the Measure evaluation
 *
 * @param theRequestDetails generally auto-populated by the HAPI server framework.
 * @param theId             the Id of the Measure to sub data for
 * @param periodStart       The start of the reporting period
 * @param periodEnd         The end of the reporting period
 * @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.
 * @return Parameters the parameters containing the MeasureReport and the evaluated Resources
 */
@Description(shortDefinition = "$collect-data", value = "Implements the <a href=\"http://hl7.org/fhir/DSTU3/measure-operation-collect-data.html\">$collect-data</a> operation found in the <a href=\"http://hl7.org/fhir/DSTU3/clinicalreasoning-module.html\">FHIR Clinical Reasoning Module</a>.")
@Operation(name = "$collect-data", idempotent = true, type = Measure.class)
public Parameters collectData(RequestDetails theRequestDetails, @IdParam IdType theId, @OperationParam(name = "periodStart") String periodStart, @OperationParam(name = "periodEnd") String periodEnd, @OperationParam(name = "subject") String subject, @OperationParam(name = "practitioner") String practitioner, @OperationParam(name = "lastReceivedOn") String lastReceivedOn) {
    MeasureReport report = measureEvaluateProvider.evaluateMeasure(theRequestDetails, theId, periodStart, periodEnd, "subject", subject, practitioner, lastReceivedOn, null, null);
    // TODO: Data collection doesn't exist?
    report.setType(MeasureReportType.SUMMARY);
    report.setGroup(null);
    Parameters parameters = newParameters(newPart("measureReport", report));
    addEvaluatedResourcesToParameters(report, parameters);
    return parameters;
}
Also used : Parameters.newParameters(org.opencds.cqf.ruler.utility.dstu3.Parameters.newParameters) Parameters(org.hl7.fhir.dstu3.model.Parameters) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 17 with Description

use of ca.uhn.fhir.model.api.annotation.Description in project beneficiary-fhir-data by CMSgov.

the class PatientResourceProvider method searchByLogicalId.

/**
 * Adds support for the FHIR "search" operation for {@link Patient}s, allowing users to search by
 * {@link Patient#getId()}.
 *
 * <p>The {@link Search} annotation indicates that this method supports the search operation.
 * There may be many different methods annotated with this {@link Search} annotation, to support
 * many different search criteria.
 *
 * @param logicalId a {@link TokenParam} (with no system, per the spec) for the {@link
 *     Patient#getId()} to try and find a matching {@link Patient} for
 * @param startIndex an {@link OptionalParam} for the startIndex (or offset) used to determine
 *     pagination
 * @param lastUpdated an {@link OptionalParam} to filter the results based on the passed date
 *     range
 * @param requestDetails a {@link RequestDetails} containing the details of the request URL, used
 *     to parse out pagination values
 * @return Returns a {@link List} of {@link Patient}s, which may contain multiple matching
 *     resources, or may also be empty.
 */
@Search
@Trace
public Bundle searchByLogicalId(@RequiredParam(name = Patient.SP_RES_ID) @Description(shortDefinition = "The patient identifier to search for") TokenParam logicalId, @OptionalParam(name = "startIndex") @Description(shortDefinition = "The offset used for result pagination") String startIndex, @OptionalParam(name = "_lastUpdated") @Description(shortDefinition = "Include resources last updated in the given range") DateRangeParam lastUpdated, RequestDetails requestDetails) {
    if (logicalId.getQueryParameterQualifier() != null)
        throw new InvalidRequestException("Unsupported query parameter qualifier: " + logicalId.getQueryParameterQualifier());
    if (logicalId.getSystem() != null && !logicalId.getSystem().isEmpty())
        throw new InvalidRequestException("Unsupported query parameter system: " + logicalId.getSystem());
    if (logicalId.getValueNotNull().isEmpty())
        throw new InvalidRequestException("Unsupported query parameter value: " + logicalId.getValue());
    List<IBaseResource> patients;
    if (loadedFilterManager.isResultSetEmpty(logicalId.getValue(), lastUpdated)) {
        patients = Collections.emptyList();
    } else {
        try {
            patients = Optional.of(read(new IdType(logicalId.getValue()), requestDetails)).filter(p -> QueryUtils.isInRange(p.getMeta().getLastUpdated().toInstant(), lastUpdated)).map(p -> Collections.singletonList((IBaseResource) p)).orElse(Collections.emptyList());
        } catch (ResourceNotFoundException e) {
            patients = Collections.emptyList();
        }
    }
    /*
     * Publish the operation name. Note: This is a bit later than we'd normally do this, as we need
     * to override the operation name that was published by the possible call to read(...), above.
     */
    RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(requestDetails);
    Operation operation = new Operation(Operation.Endpoint.V1_PATIENT);
    operation.setOption("by", "id");
    // track all api hdrs
    requestHeader.getNVPairs().forEach((n, v) -> operation.setOption(n, v.toString()));
    operation.setOption("_lastUpdated", Boolean.toString(lastUpdated != null && !lastUpdated.isEmpty()));
    operation.publishOperationName();
    OffsetLinkBuilder paging = new OffsetLinkBuilder(requestDetails, "/Patient?");
    Bundle bundle = TransformerUtils.createBundle(paging, patients, loadedFilterManager.getTransactionTime());
    return bundle;
}
Also used : IdParam(ca.uhn.fhir.rest.annotation.IdParam) Arrays(java.util.Arrays) Bundle(org.hl7.fhir.dstu3.model.Bundle) PatientLinkBuilder(gov.cms.bfd.server.war.commons.PatientLinkBuilder) Identifier(org.hl7.fhir.dstu3.model.Identifier) Description(ca.uhn.fhir.model.api.annotation.Description) IdType(org.hl7.fhir.dstu3.model.IdType) NoResultException(javax.persistence.NoResultException) StringUtils(org.apache.commons.lang3.StringUtils) BigDecimal(java.math.BigDecimal) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Predicate(javax.persistence.criteria.Predicate) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Map(java.util.Map) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) JoinType(javax.persistence.criteria.JoinType) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) LoadedFilterManager(gov.cms.bfd.server.war.commons.LoadedFilterManager) SingularAttribute(javax.persistence.metamodel.SingularAttribute) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdDt(ca.uhn.fhir.model.primitive.IdDt) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) BeneficiaryMonthly_(gov.cms.bfd.model.rif.BeneficiaryMonthly_) QueryHints(org.hibernate.jpa.QueryHints) Collectors(java.util.stream.Collectors) BeneficiaryMonthly(gov.cms.bfd.model.rif.BeneficiaryMonthly) Objects(java.util.Objects) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) BeneficiaryHistory_(gov.cms.bfd.model.rif.BeneficiaryHistory_) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) Year(java.time.Year) LocalDate(java.time.LocalDate) Timer(com.codahale.metrics.Timer) Optional(java.util.Optional) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) QueryUtils(gov.cms.bfd.server.war.commons.QueryUtils) Trace(com.newrelic.api.agent.Trace) HashMap(java.util.HashMap) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) Beneficiary_(gov.cms.bfd.model.rif.Beneficiary_) ArrayList(java.util.ArrayList) RequiredParam(ca.uhn.fhir.rest.annotation.RequiredParam) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Search(ca.uhn.fhir.rest.annotation.Search) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) CommonHeaders(gov.cms.bfd.server.war.commons.CommonHeaders) LinkedList(java.util.LinkedList) Root(javax.persistence.criteria.Root) Read(ca.uhn.fhir.rest.annotation.Read) OffsetLinkBuilder(gov.cms.bfd.server.war.commons.OffsetLinkBuilder) MetricRegistry(com.codahale.metrics.MetricRegistry) Operation(gov.cms.bfd.server.war.Operation) EntityManager(javax.persistence.EntityManager) PersistenceContext(javax.persistence.PersistenceContext) TokenParam(ca.uhn.fhir.rest.param.TokenParam) Component(org.springframework.stereotype.Component) Patient(org.hl7.fhir.dstu3.model.Patient) MDC(org.slf4j.MDC) YearMonth(java.time.YearMonth) Collections(java.util.Collections) OffsetLinkBuilder(gov.cms.bfd.server.war.commons.OffsetLinkBuilder) Bundle(org.hl7.fhir.dstu3.model.Bundle) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) Operation(gov.cms.bfd.server.war.Operation) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) IdType(org.hl7.fhir.dstu3.model.IdType) Trace(com.newrelic.api.agent.Trace) Search(ca.uhn.fhir.rest.annotation.Search)

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