use of org.hl7.fhir.r4b.model.OperationDefinition in project pathling by aehrc.
the class ConformanceProvider method buildResources.
@Nonnull
private List<CapabilityStatementRestResourceComponent> buildResources() {
final List<CapabilityStatementRestResourceComponent> resources = new ArrayList<>();
final Set<ResourceType> supported = FhirServer.supportedResourceTypes();
final Set<ResourceType> supportedResourceTypes = supported.isEmpty() ? EnumSet.noneOf(ResourceType.class) : EnumSet.copyOf(supported);
for (final ResourceType resourceType : supportedResourceTypes) {
final CapabilityStatementRestResourceComponent resource = new CapabilityStatementRestResourceComponent(new CodeType(resourceType.toCode()));
resource.setProfile(FHIR_RESOURCE_BASE + resourceType.toCode());
// Add the search operation to all resources.
final ResourceInteractionComponent search = new ResourceInteractionComponent();
search.setCode(TypeRestfulInteraction.SEARCHTYPE);
resource.getInteraction().add(search);
// Add the create and update operations to all resources.
final ResourceInteractionComponent create = new ResourceInteractionComponent();
final ResourceInteractionComponent update = new ResourceInteractionComponent();
create.setCode(TypeRestfulInteraction.CREATE);
update.setCode(TypeRestfulInteraction.UPDATE);
resource.getInteraction().add(create);
resource.getInteraction().add(update);
// Add the `aggregate` operation to all resources.
final CanonicalType aggregateOperationUri = new CanonicalType(getOperationUri("aggregate"));
final CapabilityStatementRestResourceOperationComponent aggregateOperation = new CapabilityStatementRestResourceOperationComponent(new StringType("aggregate"), aggregateOperationUri);
resource.addOperation(aggregateOperation);
// Add the `fhirPath` search parameter to all resources.
final CapabilityStatementRestResourceOperationComponent searchOperation = new CapabilityStatementRestResourceOperationComponent();
searchOperation.setName("fhirPath");
searchOperation.setDefinition(getOperationUri("search"));
resource.addOperation(searchOperation);
resources.add(resource);
}
// Add the read operation to the OperationDefinition resource.
final String opDefCode = ResourceType.OPERATIONDEFINITION.toCode();
final CapabilityStatementRestResourceComponent opDefResource = new CapabilityStatementRestResourceComponent(new CodeType(opDefCode));
opDefResource.setProfile(FHIR_RESOURCE_BASE + opDefCode);
final ResourceInteractionComponent readInteraction = new ResourceInteractionComponent();
readInteraction.setCode(TypeRestfulInteraction.READ);
opDefResource.addInteraction(readInteraction);
resources.add(opDefResource);
return resources;
}
use of org.hl7.fhir.r4b.model.OperationDefinition in project pathling by aehrc.
the class OperationDefinitionProvider method getOperationDefinitionById.
/**
* Handles all read requests to the OperationDefinition resource.
*
* @param id the ID of the desired OperationDefinition
* @return an {@link OperationDefinition} resource
*/
@Read
@SuppressWarnings("unused")
public OperationDefinition getOperationDefinitionById(@Nullable @IdParam final IIdType id) {
checkUserInput(id != null, "Missing ID parameter");
final String idString = id.getValue();
final OperationDefinition resource = resources.get(idString);
if (resource == null) {
throw new ResourceNotFoundError("OperationDefinition not found: " + idString);
}
return resource;
}
use of org.hl7.fhir.r4b.model.OperationDefinition in project pathling by aehrc.
the class OperationDefinitionProvider method load.
@Nonnull
private OperationDefinition load(@Nonnull final String resourcePath) {
@Nullable final InputStream resourceStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath);
checkNotNull(resourceStream);
final OperationDefinition operationDefinition = (OperationDefinition) jsonParser.parseResource(resourceStream);
final String id = String.format("%1$s%2$s", operationDefinition.getName(), version.getMajorVersion().map(v -> String.format("-%1$s", v)).orElse(""));
operationDefinition.setId(id);
final String url = String.format("%1$s/OperationDefinition/%2$s", ConformanceProvider.URI_BASE, id);
operationDefinition.setUrl(url);
operationDefinition.setVersion(version.getBuildVersion().orElse(UNKNOWN_VERSION));
return operationDefinition;
}
use of org.hl7.fhir.r4b.model.OperationDefinition in project pathling by aehrc.
the class AggregateResponse method toParameters.
/**
* Converts this to a {@link Parameters} resource, based on the definition of the result of the
* "aggregate" operation within the OperationDefinition.
*
* @return a new {@link Parameters} object
*/
public Parameters toParameters() {
final Parameters parameters = new Parameters();
groupings.forEach(grouping -> {
final ParametersParameterComponent groupingParameter = new ParametersParameterComponent();
groupingParameter.setName("grouping");
grouping.getLabels().forEach(label -> {
final ParametersParameterComponent labelPart = new ParametersParameterComponent();
labelPart.setName("label");
// A "null" value is represented by the absence of a value within FHIR.
label.ifPresent(labelPart::setValue);
groupingParameter.getPart().add(labelPart);
});
grouping.getResults().forEach(result -> {
final ParametersParameterComponent resultPart = new ParametersParameterComponent();
resultPart.setName("result");
// A "null" value is represented by the absence of a value within FHIR.
result.ifPresent(resultPart::setValue);
groupingParameter.getPart().add(resultPart);
});
if (grouping.getDrillDown().isPresent()) {
final String drillDown = grouping.getDrillDown().get();
final ParametersParameterComponent drillDownPart = new ParametersParameterComponent();
drillDownPart.setName("drillDown");
drillDownPart.setValue(new StringType(drillDown));
groupingParameter.getPart().add(drillDownPart);
}
parameters.getParameter().add(groupingParameter);
});
return parameters;
}
use of org.hl7.fhir.r4b.model.OperationDefinition in project cqf-ruler by DBCG.
the class CareGapsProvider method careGapsReport.
/**
* Implements the <a href=
* "http://build.fhir.org/ig/HL7/davinci-deqm/OperationDefinition-care-gaps.html">$care-gaps</a>
* operation found in the
* <a href="http://build.fhir.org/ig/HL7/davinci-deqm/index.html">Da Vinci DEQM
* FHIR Implementation Guide</a> that overrides the <a href=
* "http://build.fhir.org/operation-measure-care-gaps.html">$care-gaps</a>
* operation found in the
* <a href="http://hl7.org/fhir/R4/clinicalreasoning-module.html">FHIR Clinical
* Reasoning Module</a>.
*
* The operation calculates measures describing gaps in care. For more details,
* reference the <a href=
* "http://build.fhir.org/ig/HL7/davinci-deqm/gaps-in-care-reporting.html">Gaps
* in Care Reporting</a> section of the
* <a href="http://build.fhir.org/ig/HL7/davinci-deqm/index.html">Da Vinci DEQM
* FHIR Implementation Guide</a>.
*
* A Parameters resource that includes zero to many document bundles that
* include Care Gap Measure Reports will be returned.
*
* Usage:
* URL: [base]/Measure/$care-gaps
*
* @param theRequestDetails generally auto-populated by the HAPI server
* framework.
* @param periodStart the start of the gaps through period
* @param periodEnd the end of the gaps through period
* @param topic the category of the measures that is of interest for
* the care gaps report
* @param subject a reference to either a Patient or Group for which
* the gaps in care report(s) will be generated
* @param practitioner a reference to a Practitioner for which the gaps in
* care report(s) will be generated
* @param organization a reference to an Organization for which the gaps in
* care report(s) will be generated
* @param status the status code of gaps in care reports that will be
* included in the result
* @param measureId the id of Measure(s) for which the gaps in care
* report(s) will be calculated
* @param measureIdentifier the identifier of Measure(s) for which the gaps in
* care report(s) will be calculated
* @param measureUrl the canonical URL of Measure(s) for which the gaps
* in care report(s) will be calculated
* @param program the program that a provider (either clinician or
* clinical organization) participates in
* @return Parameters of bundles of Care Gap Measure Reports
*/
// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
@Description(shortDefinition = "$care-gaps", value = "Implements the <a href=\"http://build.fhir.org/ig/HL7/davinci-deqm/OperationDefinition-care-gaps.html\">$care-gaps</a> operation found in the <a href=\"http://build.fhir.org/ig/HL7/davinci-deqm/index.html\">Da Vinci DEQM FHIR Implementation Guide</a> which is an extension of the <a href=\"http://build.fhir.org/operation-measure-care-gaps.html\">$care-gaps</a> operation found in the <a href=\"http://hl7.org/fhir/R4/clinicalreasoning-module.html\">FHIR Clinical Reasoning Module</a>.")
@Operation(name = "$care-gaps", idempotent = true, type = Measure.class)
public Parameters careGapsReport(RequestDetails theRequestDetails, @OperationParam(name = "periodStart") String periodStart, @OperationParam(name = "periodEnd") String periodEnd, @OperationParam(name = "topic") List<String> topic, @OperationParam(name = "subject") String subject, @OperationParam(name = "practitioner") String practitioner, @OperationParam(name = "organization") String organization, @OperationParam(name = "status") List<String> status, @OperationParam(name = "measureId") List<String> measureId, @OperationParam(name = "measureIdentifier") List<String> measureIdentifier, @OperationParam(name = "measureUrl") List<CanonicalType> measureUrl, @OperationParam(name = "program") List<String> program) {
validateConfiguration(theRequestDetails);
validateParameters(theRequestDetails);
// TODO: filter by topic.
// TODO: filter by program.
List<Measure> measures = ensureMeasures(getMeasures(measureId, measureIdentifier, measureUrl, theRequestDetails));
List<Patient> patients;
if (!Strings.isNullOrEmpty(subject)) {
patients = getPatientListFromSubject(subject);
} else {
// TODO: implement non subject parameters (practitioner and organization)
throw new NotImplementedException("Non subject parameters have not been implemented.");
}
Parameters result = initializeResult();
(patients).forEach(patient -> {
Parameters.ParametersParameterComponent patientParameter = patientReports(theRequestDetails, periodStart, periodEnd, patient, status, measures, organization);
if (patientParameter != null) {
result.addParameter(patientParameter);
}
});
return result;
}
Aggregations