use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class ExtractProviderIT method testExtract.
@Test
public void testExtract() throws IOException, URISyntaxException {
String examplePatient = "example_patient.json";
String exampleQuestionnaire = "questionnaire_1559.json";
String exampleQR = "questionnaire_response_1558.json";
loadResource(examplePatient);
loadResource(exampleQuestionnaire);
QuestionnaireResponse questionnaireResponse = (QuestionnaireResponse) loadResource(exampleQR);
Parameters params = new Parameters();
params.addParameter().setName("questionnaireResponse").setResource(questionnaireResponse);
Bundle actual = getClient().operation().onType(QuestionnaireResponse.class).named("$extract").withParameters(params).returnResourceType(Bundle.class).execute();
assertNotNull(actual);
// Expecting one observation per item
assertEquals(5, actual.getEntry().size());
// Ensure the Observations were saved to the local server
for (Bundle.BundleEntryComponent bec : actual.getEntry()) {
assertEquals("201 Created", bec.getResponse().getStatus());
}
}
use of org.hl7.fhir.r4.model.Parameters 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;
}
use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class ReportProviderIT method testSubjectIsNotPatientOrGroup.
@Test
public void testSubjectIsNotPatientOrGroup() 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("subject").setValue(new StringType("ra-patient01"));
assertThrows(InternalErrorException.class, () -> {
getClient().operation().onType(MeasureReport.class).named("$report").withParameters(params).returnResourceType(Parameters.class).execute();
});
}
use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class ReportProviderIT method testMissingPeriodStartParam.
@Test
public void testMissingPeriodStartParam() throws IOException {
Parameters params = new Parameters();
params.addParameter().setName("periodEnd").setValue(new StringType("2021-12-31"));
params.addParameter().setName("subject").setValue(new StringType("Patient/testReport01"));
assertThrows(InternalErrorException.class, () -> {
getClient().operation().onType(MeasureReport.class).named("$report").withParameters(params).returnResourceType(Parameters.class).execute();
});
}
use of org.hl7.fhir.r4.model.Parameters in project cqf-ruler by DBCG.
the class ReportProviderIT method testMissingPeriodEndParam.
@Test
public void testMissingPeriodEndParam() throws IOException {
Parameters params = new Parameters();
params.addParameter().setName("periodStart").setValue(new StringType("2021-01-01"));
params.addParameter().setName("subject").setValue(new StringType("Patient/testReport01"));
assertThrows(InternalErrorException.class, () -> {
getClient().operation().onType(MeasureReport.class).named("$report").withParameters(params).returnResourceType(Parameters.class).execute();
});
}
Aggregations