use of org.hl7.fhir.r4.model.Group 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.Group in project cqf-ruler by DBCG.
the class ReportProvider method validateParameters.
private Period validateParameters(String periodStart, String periodEnd, String subject) {
if (periodStart == null) {
throw new IllegalArgumentException("Parameter 'periodStart' is required.");
}
if (periodEnd == null) {
throw new IllegalArgumentException("Parameter 'periodEnd' is required.");
}
Date periodStartDate = Operations.resolveRequestDate(periodStart, true);
Date periodEndDate = Operations.resolveRequestDate(periodEnd, false);
if (periodStartDate.after(periodEndDate)) {
throw new IllegalArgumentException("Parameter 'periodStart' must be before 'periodEnd'.");
}
if (subject == null) {
throw new IllegalArgumentException("Parameter 'subject' is required.");
}
if (!subject.startsWith("Patient/") && !subject.startsWith("Group/")) {
throw new IllegalArgumentException("Parameter 'subject' must be in the format 'Patient/[id]' or 'Group/[id]'.");
}
return new Period().setStart(periodStartDate).setEnd(periodEndDate);
}
use of org.hl7.fhir.r4.model.Group in project cqf-ruler by DBCG.
the class ReportProviderIT method testSubjectGroup.
// TODO: add the count of patients returned
@Test
public void testSubjectGroup() 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("Group/ra-group01"));
loadResource("Patient-ra-patient01.json");
loadResource("Group-ra-group01.json");
assertDoesNotThrow(() -> {
getClient().operation().onType(MeasureReport.class).named("$report").withParameters(params).returnResourceType(Parameters.class).execute();
});
}
use of org.hl7.fhir.r4.model.Group in project cqf-ruler by DBCG.
the class ReportProviderIT method testSubjectPatientNotFoundInGroup.
// This test requires the following application setting:
// enforce_referential_integrity_on_write: false
@Disabled("Provider needs to be updated to use parameter validation and then this test should be re-enabled")
@Test
public void testSubjectPatientNotFoundInGroup() 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("Group/ra-group00"));
loadResource("Group-ra-group00.json");
Group group = getClient().read().resource(Group.class).withId("ra-group00").execute();
assertNotNull(group);
assertThrows(ResourceNotFoundException.class, () -> {
getClient().operation().onType(MeasureReport.class).named("$report").withParameters(params).returnResourceType(Parameters.class).execute();
});
}
use of org.hl7.fhir.r4.model.Group in project cqf-ruler by DBCG.
the class Session method applyPlanDefinition.
@Operation(name = "$apply", idempotent = true, type = PlanDefinition.class)
public CarePlan applyPlanDefinition(RequestDetails theRequest, @IdParam IdType theId, @OperationParam(name = "patient") String patientId, @OperationParam(name = "encounter") String encounterId, @OperationParam(name = "practitioner") String practitionerId, @OperationParam(name = "organization") String organizationId, @OperationParam(name = "userType") String userType, @OperationParam(name = "userLanguage") String userLanguage, @OperationParam(name = "userTaskContext") String userTaskContext, @OperationParam(name = "setting") String setting, @OperationParam(name = "settingContext") String settingContext) throws IOException, FHIRException {
PlanDefinition planDefinition = this.planDefinitionDao.read(theId);
if (planDefinition == null) {
throw new IllegalArgumentException("Couldn't find PlanDefinition " + theId);
}
logger.info("Performing $apply operation on PlanDefinition/{}", theId);
CarePlanBuilder builder = new CarePlanBuilder();
builder.buildInstantiatesCanonical(planDefinition.getUrl()).buildSubject(new Reference(patientId)).buildStatus(CarePlan.CarePlanStatus.DRAFT);
if (encounterId != null)
builder.buildEncounter(new Reference(encounterId));
if (practitionerId != null)
builder.buildAuthor(new Reference(practitionerId));
if (organizationId != null)
builder.buildAuthor(new Reference(organizationId));
if (userLanguage != null)
builder.buildLanguage(userLanguage);
// Each Group of actions shares a RequestGroup
RequestGroupBuilder requestGroupBuilder = new RequestGroupBuilder().buildStatus().buildIntent();
Session session = new Session(planDefinition, builder, patientId, encounterId, practitionerId, organizationId, userType, userLanguage, userTaskContext, setting, settingContext, requestGroupBuilder);
return (CarePlan) ContainedHelper.liftContainedResourcesToParent(resolveActions(session, theRequest));
}
Aggregations