use of org.hl7.fhir.utilities.graphql.Operation in project cqf-ruler by DBCG.
the class ProcessMessageProviderIT method testProcessMessage.
@Test
public void testProcessMessage() throws IOException {
String packagePrefix = "org/opencds/cqf/ruler/casereporting/r4/";
Bundle bundle = (Bundle) loadResource(packagePrefix + "example-eicr.json");
Bundle returnBundle = getClient().operation().onServer().named("$process-message-bundle").withParameter(Parameters.class, "content", bundle).returnResourceType(Bundle.class).execute();
assertNotNull(returnBundle);
assertNotNull(getClient().read().resource(Patient.class).withId("patient-12742542").execute());
assertNotNull(getClient().read().resource(Encounter.class).withId("encounter-97953898").execute());
assertNotNull(getClient().read().resource(MeasureReport.class).withId("diabetes-mp").execute());
}
use of org.hl7.fhir.utilities.graphql.Operation in project cqf-ruler by DBCG.
the class HelloWorldProvider method hello_world.
/**
* Implements the $hello-world operation found in the
* <a href="https://www.hl7.org/fhir/clinicalreasoning-module.html">FHIR CR
* Module</a>
*
* @return a greeting
*/
@Description(shortDefinition = "returns a greeting", value = "Implements the $hello-world operation found in the <a href=\"https://www.hl7.org/fhir/clinicalreasoning-module.html\">FHIR CR Module</a>")
@Operation(idempotent = true, name = "$hello-world")
public OperationOutcome hello_world() {
OperationOutcome outcome = new OperationOutcome();
outcome.addIssue().setDiagnostics(helloWorldProperties.getMessage());
return outcome;
}
use of org.hl7.fhir.utilities.graphql.Operation in project cqf-ruler by DBCG.
the class HelloWorldProviderIT method testHelloWorldConfig.
@Test
public void testHelloWorldConfig() {
OperationOutcome outcome = getClient().operation().onServer().named("$hello-world").withNoParameters(Parameters.class).returnResourceType(OperationOutcome.class).execute();
assertNotNull(outcome);
assertEquals("Howdy", outcome.getIssueFirstRep().getDiagnostics());
}
use of org.hl7.fhir.utilities.graphql.Operation in project cqf-ruler by DBCG.
the class Stu3EvaluationContext method applyCqlToResources.
@Override
List<Object> applyCqlToResources(List<Object> resources) {
if (resources == null || resources.isEmpty()) {
return new ArrayList<>();
}
Bundle bundle = new Bundle();
for (Object res : resources) {
bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) res));
}
Parameters parameters = new Parameters();
parameters.addParameter().setName("resourceBundle").setResource(bundle);
Parameters ret = this.getSystemFhirClient().operation().onType(Bundle.class).named("$apply-cql").withParameters(parameters).execute();
Bundle appliedResources = (Bundle) ret.getParameter().get(0).getResource();
return appliedResources.getEntry().stream().map(Bundle.BundleEntryComponent::getResource).collect(Collectors.toList());
}
use of org.hl7.fhir.utilities.graphql.Operation 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());
}
}
Aggregations