Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isolate getsubjects method in Measure Processor #361

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,34 @@ public MeasureReport evaluateMeasure(
String reportType,
List<String> subjectIds,
IBaseBundle additionalData) {

var evalType = MeasureEvalType.fromCode(reportType)
.orElse(
subjectIds.get(0) == null || subjectIds == null || subjectIds.isEmpty()
? MeasureEvalType.POPULATION
: MeasureEvalType.SUBJECT);

var actualRepo = this.repository;
if (additionalData != null) {
actualRepo = new FederatedRepository(
this.repository, new InMemoryFhirRepository(this.repository.fhirContext(), additionalData));
}
var subjects =
subjectProvider.getSubjects(actualRepo, evalType, subjectIds).collect(Collectors.toList());

return this.evaluateMeasure(measure, periodStart, periodEnd, reportType, subjects, additionalData, evalType);
}

public MeasureReport evaluateMeasure(
Either3<CanonicalType, IdType, Measure> measure,
String periodStart,
String periodEnd,
String reportType,
List<String> subjectIds,
IBaseBundle additionalData,
MeasureEvalType evalType) {
var m = measure.fold(this::resolveByUrl, this::resolveById, Function.identity());
return this.evaluateMeasure(m, periodStart, periodEnd, reportType, subjectIds, additionalData);
return this.evaluateMeasure(m, periodStart, periodEnd, reportType, subjectIds, additionalData, evalType);
}

protected MeasureReport evaluateMeasure(
Expand All @@ -63,7 +89,8 @@ protected MeasureReport evaluateMeasure(
String periodEnd,
String reportType,
List<String> subjectIds,
IBaseBundle additionalData) {
IBaseBundle additionalData,
MeasureEvalType evalType) {

if (!measure.hasLibrary()) {
throw new IllegalArgumentException(
Expand All @@ -83,23 +110,16 @@ protected MeasureReport evaluateMeasure(

context.getState().init(lib.getLibrary());

var evalType = MeasureEvalType.fromCode(reportType)
.orElse(
subjectIds.get(0) == null || subjectIds == null || subjectIds.isEmpty()
? MeasureEvalType.POPULATION
: MeasureEvalType.SUBJECT);

var actualRepo = this.repository;
if (additionalData != null) {
actualRepo = new FederatedRepository(
this.repository, new InMemoryFhirRepository(this.repository.fhirContext(), additionalData));
if (evalType == null) {
evalType = MeasureEvalType.fromCode(reportType)
.orElse(
subjectIds.get(0) == null || subjectIds == null || subjectIds.isEmpty()
? MeasureEvalType.POPULATION
: MeasureEvalType.SUBJECT);
}

var subjects =
subjectProvider.getSubjects(actualRepo, evalType, subjectIds).collect(Collectors.toList());

R4MeasureEvaluation measureEvaluator = new R4MeasureEvaluation(context, measure);
return measureEvaluator.evaluate(evalType, subjects, measurementPeriod);
return measureEvaluator.evaluate(evalType, subjectIds, measurementPeriod);
}

protected Measure resolveByUrl(CanonicalType url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public MeasureReport evaluate(

if (StringUtils.isNotBlank(practitioner)) {
if (practitioner.indexOf("/") == -1) {
subjectId = "Practitioner/".concat(practitioner);
practitioner = "Practitioner/".concat(practitioner);
}
subjectId = practitioner;
}
Expand Down