use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.
the class MeasureDataProcessProviderIT method testMeasureReportExtractLineListData.
@Test
public void testMeasureReportExtractLineListData() throws IOException {
String packagePrefix = "org/opencds/cqf/ruler/casereporting/r4/";
loadResource(packagePrefix + "Patient-ra-patient01.json");
loadResource(packagePrefix + "Patient-ra-patient02.json");
loadResource(packagePrefix + "Patient-ra-patient03.json");
loadResource(packagePrefix + "Group-ra-group00.json");
loadResource(packagePrefix + "Group-ra-group01.json");
loadResource(packagePrefix + "Group-ra-group02.json");
loadResource(packagePrefix + "MeasureReport-ra-measurereport01.json");
MeasureReport measureReport = getClient().read().resource(MeasureReport.class).withId("ra-measurereport01").execute();
assertNotNull(measureReport);
Parameters params = new Parameters();
params.addParameter().setName("measureReport").setResource(measureReport);
params.addParameter().setName("subjectList").setValue(null);
Bundle returnBundle = getClient().operation().onType(MeasureReport.class).named("$extract-line-list-data").withParameters(params).returnResourceType(Bundle.class).execute();
assertNotNull(returnBundle);
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.
the class SubmitDataProviderIT method testSubmitData.
@Test
public void testSubmitData() {
// Create a MR and a resource
MeasureReport mr = newResource(MeasureReport.class, "test-mr");
Observation obs = newResource(Observation.class, "test-obs");
// Submit it
mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "test-m"), mr, Lists.newArrayList(obs));
// Check if they made it to the db
Observation savedObs = read(obs.getIdElement());
assertNotNull(savedObs);
MeasureReport savedMr = read(mr.getIdElement());
assertNotNull(savedMr);
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.
the class ReportProvider method patientReport.
private Parameters.ParametersParameterComponent patientReport(Patient thePatient, Period thePeriod, String serverBase) {
String patientId = thePatient.getIdElement().getIdPart();
final Map<IIdType, IAnyResource> bundleEntries = new HashMap<>();
bundleEntries.put(thePatient.getIdElement(), thePatient);
ReferenceParam subjectParam = new ReferenceParam(patientId);
search(MeasureReport.class, Searches.byParam("subject", subjectParam)).getAllResourcesTyped().forEach(measureReport -> {
if (measureReport.getPeriod().getEnd().before(thePeriod.getStart()) || measureReport.getPeriod().getStart().after(thePeriod.getEnd())) {
return;
}
bundleEntries.putIfAbsent(measureReport.getIdElement(), measureReport);
getEvaluatedResources(measureReport).values().forEach(resource -> bundleEntries.putIfAbsent(resource.getIdElement(), resource));
});
Bundle patientReportBundle = new Bundle();
patientReportBundle.setMeta(new Meta().addProfile(PATIENT_REPORT_PROFILE_URL));
patientReportBundle.setType(Bundle.BundleType.COLLECTION);
patientReportBundle.setTimestamp(new Date());
patientReportBundle.setId(patientId + "-report");
patientReportBundle.setIdentifier(new Identifier().setSystem("urn:ietf:rfc:3986").setValue("urn:uuid:" + UUID.randomUUID().toString()));
bundleEntries.entrySet().forEach(resource -> patientReportBundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource.getValue()).setFullUrl(Operations.getFullUrl(serverBase, resource.getValue().fhirType(), resource.getValue().getIdElement().getIdPart()))));
Parameters.ParametersParameterComponent patientParameter = new Parameters.ParametersParameterComponent();
patientParameter.setResource(patientReportBundle);
patientParameter.setId(thePatient.getIdElement().getIdPart() + "-report");
patientParameter.setName("return");
return patientParameter;
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.
the class CollectDataProviderIT method testCollectData.
@Test
public void testCollectData() {
// Create test Measure
String cql = CqlBuilder.newCqlLibrary("4.0.1").addExpression("Initial Population", "exists([Observation])").build();
Library lib = Libraries.library(cql);
Measure m = MeasureBuilder.newCohortMeasure(lib).build();
this.update(lib);
this.update(m);
// Create test data
Patient john = Patients.john_doe();
this.create(john);
Observation obs = newResource(Observation.class).setSubject(new Reference(john));
this.create(obs);
Encounter enc = newResource(Encounter.class).setSubject(new Reference(john));
this.create(enc);
// Submit it
Parameters results = collectDataProvider.collectData(new SystemRequestDetails(), m.getIdElement(), "2019-01-01", "2019-12-31", Ids.simple(john), null, null);
List<ParametersParameterComponent> resources = org.opencds.cqf.ruler.utility.r4.Parameters.getPartsByName(results, "resource");
assertEquals(1, resources.size());
assertEquals("Observation", resources.get(0).getResource().fhirType());
List<ParametersParameterComponent> reports = org.opencds.cqf.ruler.utility.r4.Parameters.getPartsByName(results, "measureReport");
assertEquals(1, reports.size());
assertEquals("MeasureReport", reports.get(0).getResource().fhirType());
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.
the class MeasureEvaluateProviderIT method testMeasureEvaluate.
@Test
public void testMeasureEvaluate() throws Exception {
String bundleAsText = stringFromResource("Exm104FhirR4MeasureBundle.json");
Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
getClient().transaction().withBundle(bundle).execute();
Parameters params = new Parameters();
params.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
params.addParameter().setName("periodEnd").setValue(new StringType("2020-01-01"));
params.addParameter().setName("reportType").setValue(new StringType("individual"));
params.addParameter().setName("subject").setValue(new StringType("Patient/numer-EXM104"));
params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM104-8.2.000")).named("$evaluate-measure").withParameters(params).returnResourceType(MeasureReport.class).execute();
assertNotNull(returnMeasureReport);
// System.out.println("Resource:"+this.getFhirContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(returnMeasureReport));
}
Aggregations