use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testDataBundleCqlExecutionProviderWithSubject.
@Test
public void testDataBundleCqlExecutionProviderWithSubject() throws Exception {
Parameters params = new Parameters();
Parameters libraryParameter = new Parameters();
params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
params.addParameter().setName("data").setResource(data);
params.addParameter().setName("useServerData").setValue(new BooleanType(false));
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testDataBundleCqlExecutionProvider.
@Test
public void testDataBundleCqlExecutionProvider() throws Exception {
Parameters params = new Parameters();
Parameters libraryParameter = new Parameters();
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
params.addParameter().setName("data").setResource(data);
params.addParameter().setName("useServerData").setValue(new BooleanType(false));
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testReferencedLibraryCqlExecutionProvider.
@Test
public void testReferencedLibraryCqlExecutionProvider() throws Exception {
Parameters params = new Parameters();
params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
Parameters libraryParameter = new Parameters();
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"simpleBooleanExpression\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(0).getValue()).asStringValue().equals("true"));
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("Boolean"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class LibraryEvaluationProviderIT method testLibraryEvaluationValidationThrows.
@Test
public void testLibraryEvaluationValidationThrows() throws IOException {
Parameters params = new Parameters();
params.addParameter().setName("periodStart").setValue(new StringType("2021-01-01"));
params.addParameter().setName("periodEnd").setValue(new StringType("2021-12-31"));
params.addParameter().setName("patientId").setValue(null);
params.addParameter().setName("context").setValue(new StringType("Patient"));
String packagePrefix = "org/opencds/cqf/ruler/cpg/r4/provider/";
loadResource(packagePrefix + "ColorectalCancerScreeningsFHIR.json");
Library lib = getClient().read().resource(Library.class).withId("ColorectalCancerScreeningsFHIR").execute();
assertNotNull(lib);
assertThrows(InternalErrorException.class, () -> {
getClient().operation().onInstance(new IdType("Library", "ColorectalCancerScreeningsFHIR")).named("$evaluate").withParameters(params).returnResourceType(Bundle.class).execute();
});
}
use of org.hl7.fhir.r4.model.Parameters in project ipf by oehf.
the class Iti67ResourceProvider method documentReferenceSearch.
@SuppressWarnings("unused")
@Search(type = DocumentReference.class)
public IBundleProvider documentReferenceSearch(@RequiredParam(name = DocumentReference.SP_PATIENT, chainWhitelist = { "", Patient.SP_IDENTIFIER }) ReferenceParam patient, @OptionalParam(name = DocumentReference.SP_STATUS) TokenOrListParam status, @OptionalParam(name = DocumentReference.SP_IDENTIFIER) TokenParam identifier, @OptionalParam(name = DocumentReference.SP_DATE) DateRangeParam date, @OptionalParam(name = STU3_INDEXED) DateRangeParam indexed, @OptionalParam(name = DocumentReference.SP_AUTHOR, chainWhitelist = { Practitioner.SP_FAMILY, Practitioner.SP_GIVEN }) ReferenceAndListParam author, @OptionalParam(name = DocumentReference.SP_CATEGORY) TokenOrListParam category, @OptionalParam(name = STU3_CLASS) TokenOrListParam class_, @OptionalParam(name = DocumentReference.SP_TYPE) TokenOrListParam type, @OptionalParam(name = DocumentReference.SP_SETTING) TokenOrListParam setting, @OptionalParam(name = DocumentReference.SP_PERIOD) DateRangeParam period, @OptionalParam(name = DocumentReference.SP_FACILITY) TokenOrListParam facility, @OptionalParam(name = DocumentReference.SP_EVENT) TokenOrListParam event, @OptionalParam(name = DocumentReference.SP_SECURITY_LABEL) TokenOrListParam securityLabel, @OptionalParam(name = STU3_SECURITY_LABEL) TokenOrListParam label, @OptionalParam(name = DocumentReference.SP_FORMAT) TokenOrListParam format, @OptionalParam(name = DocumentReference.SP_RELATED, chainWhitelist = { "", DocumentReference.SP_IDENTIFIER }) ReferenceOrListParam related, // -> related.identifier
@OptionalParam(name = STU3_RELATED_ID) TokenOrListParam relatedId, // -> related
@OptionalParam(name = STU3_RELATED_REF) ReferenceOrListParam relatedRef, // Extension to ITI-67
@OptionalParam(name = IAnyResource.SP_RES_ID) TokenParam resourceId, @Sort SortSpec sortSpec, @IncludeParam Set<Include> includeSpec, RequestDetails requestDetails, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
// Be graceful and accept STU3 parameters as well
var dateParam = date != null ? date : indexed;
var categoryParam = category != null ? category : class_;
var securityLabelParam = securityLabel != null ? securityLabel : label;
// Handle "related" parameters
ReferenceOrListParam relatedParam = new ReferenceOrListParam();
TokenOrListParam relatedIdParam = new TokenOrListParam();
if (relatedRef != null) {
relatedParam = relatedRef;
} else if (relatedId != null) {
relatedIdParam = relatedId;
} else if (related != null) {
related.getValuesAsQueryTokens().stream().filter(referenceParam -> !DocumentReference.SP_IDENTIFIER.equals(referenceParam.getChain())).forEach(relatedParam::addOr);
related.getValuesAsQueryTokens().stream().filter(referenceParam -> DocumentReference.SP_IDENTIFIER.equals(referenceParam.getChain())).map(referenceParam -> referenceParam.toTokenParam(getFhirContext())).forEach(relatedIdParam::addOr);
}
var searchParameters = Iti67SearchParameters.builder().status(status).identifier(identifier).date(dateParam).category(categoryParam).type(type).setting(setting).period(period).facility(facility).event(event).securityLabel(securityLabelParam).format(format).related(relatedParam).relatedId(relatedIdParam)._id(resourceId).sortSpec(sortSpec).includeSpec(includeSpec).fhirContext(getFhirContext()).build();
searchParameters.setAuthor(author);
var patientChain = patient.getChain();
if (Patient.SP_IDENTIFIER.equals(patientChain)) {
searchParameters.setPatientIdentifier(patient.toTokenParam(getFhirContext()));
} else if (patientChain == null || patientChain.isEmpty()) {
searchParameters.setPatientReference(patient);
}
// Run down the route
return requestBundleProvider(null, searchParameters, ResourceType.DocumentReference.name(), httpServletRequest, httpServletResponse, requestDetails);
}
Aggregations