-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #701 from lantanagroup/LNK-1523
LNK-1523: Update measure evaluation to evaluate directly within the API
- Loading branch information
Showing
43 changed files
with
384 additions
and
403 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
api/src/main/java/com/lantanagroup/link/api/MeasureDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lantanagroup.link.api; | ||
|
||
import com.lantanagroup.link.StreamUtils; | ||
import lombok.Getter; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.hl7.fhir.r4.model.Bundle; | ||
import org.hl7.fhir.r4.model.Measure; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
public class MeasureDef { | ||
private final Measure measure; | ||
private final List<IBaseResource> resources; | ||
|
||
public MeasureDef(Bundle bundle) { | ||
measure = bundle.getEntry().stream() | ||
.map(Bundle.BundleEntryComponent::getResource) | ||
.filter(resource -> resource instanceof Measure) | ||
.map(resource -> (Measure) resource) | ||
.reduce(StreamUtils::toOnlyElement) | ||
.orElseThrow(); | ||
|
||
// Ensure all populations have an ID | ||
for (Measure.MeasureGroupComponent group : measure.getGroup()) { | ||
for (Measure.MeasureGroupPopulationComponent population : group.getPopulation()) { | ||
if (!population.hasId()) { | ||
population.setId(population.getCode().getCodingFirstRep().getCode()); | ||
} | ||
} | ||
} | ||
|
||
resources = bundle.getEntry().stream() | ||
.map(Bundle.BundleEntryComponent::getResource) | ||
.filter(resource -> !(resource instanceof Measure)) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
Oops, something went wrong.