-
Notifications
You must be signed in to change notification settings - Fork 49
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 #467 from DBCG/feature-gic-plugin
Feature gic plugin
- Loading branch information
Showing
39 changed files
with
312,082 additions
and
213 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
core/src/main/java/org/opencds/cqf/ruler/behavior/ConfigurationUser.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,49 @@ | ||
package org.opencds.cqf.ruler.behavior; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public interface ConfigurationUser { | ||
static final ConfigurationSet configurations = new ConfigurationSet(); | ||
|
||
public abstract void validateConfiguration(); | ||
|
||
default ConfigurationUser validateConfiguration(Object theConfiguration, boolean theExpression, String theMessage) { | ||
if (configurationValid(theConfiguration)) { | ||
return this; | ||
} | ||
|
||
try { | ||
checkNotNull(theConfiguration); | ||
checkArgument(theExpression, theMessage); | ||
} catch (Exception e) { | ||
setConfigurationInvalid(theConfiguration); | ||
throw e; | ||
} | ||
|
||
return this; | ||
} | ||
|
||
default void setConfigurationValid(Object theConfiguration) { | ||
configurations.getConfigurations().add(theConfiguration); | ||
} | ||
|
||
default void setConfigurationInvalid(Object theConfiguration) { | ||
configurations.getConfigurations().remove(theConfiguration); | ||
} | ||
|
||
default boolean configurationValid(Object theConfiguration) { | ||
return configurations.getConfigurations().contains(theConfiguration); | ||
} | ||
|
||
class ConfigurationSet { | ||
private final Set<Object> configurations = new HashSet<>(); | ||
|
||
public Set<Object> getConfigurations() { | ||
return this.configurations; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
core/src/main/java/org/opencds/cqf/ruler/behavior/r4/MeasureReportUser.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,44 @@ | ||
package org.opencds.cqf.ruler.behavior.r4; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.hl7.fhir.instance.model.api.IIdType; | ||
import org.hl7.fhir.r4.model.Resource; | ||
import org.opencds.cqf.ruler.behavior.DaoRegistryUser; | ||
import org.opencds.cqf.ruler.behavior.IdCreator; | ||
import org.opencds.cqf.ruler.utility.Ids; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public interface MeasureReportUser extends DaoRegistryUser, IdCreator { | ||
static final Logger ourLog = LoggerFactory.getLogger(ParameterUser.class); | ||
|
||
public static final String MEASUREREPORT_IMPROVEMENT_NOTATION_SYSTEM = "http://terminology.hl7.org/CodeSystem/measure-improvement-notation"; | ||
public static final String MEASUREREPORT_MEASURE_POPULATION_SYSTEM = "http://terminology.hl7.org/CodeSystem/measure-population"; | ||
|
||
public default Map<String, Resource> getEvaluatedResources(org.hl7.fhir.r4.model.MeasureReport report) { | ||
Map<String, Resource> resources = new HashMap<>(); | ||
getEvaluatedResources(report, resources); | ||
|
||
return resources; | ||
} | ||
|
||
public default MeasureReportUser getEvaluatedResources(org.hl7.fhir.r4.model.MeasureReport report, | ||
Map<String, Resource> resources) { | ||
report.getEvaluatedResource().forEach(evaluatedResource -> { | ||
IIdType resourceId = evaluatedResource.getReferenceElement(); | ||
if (resourceId.getResourceType() == null || resources.containsKey(Ids.simple(resourceId))) { | ||
return; | ||
} | ||
IBaseResource resourceBase = read(resourceId); | ||
if (resourceBase instanceof Resource) { | ||
Resource resource = (Resource) resourceBase; | ||
resources.put(Ids.simple(resourceId), resource); | ||
} | ||
}); | ||
|
||
return this; | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
core/src/main/java/org/opencds/cqf/ruler/behavior/r4/ParameterUser.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,107 @@ | ||
package org.opencds.cqf.ruler.behavior.r4; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.lang3.NotImplementedException; | ||
import org.hl7.fhir.r4.model.CanonicalType; | ||
import org.hl7.fhir.r4.model.Group; | ||
import org.hl7.fhir.r4.model.Measure; | ||
import org.hl7.fhir.r4.model.Patient; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.opencds.cqf.ruler.behavior.DaoRegistryUser; | ||
import org.opencds.cqf.ruler.behavior.IdCreator; | ||
import org.opencds.cqf.ruler.utility.Searches; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import ca.uhn.fhir.rest.api.server.RequestDetails; | ||
|
||
public interface ParameterUser extends DaoRegistryUser, IdCreator { | ||
static final Logger ourLog = LoggerFactory.getLogger(ParameterUser.class); | ||
|
||
// TODO: document all these | ||
// TODO: unit test all these | ||
void validateParameters(RequestDetails theRequestDetails); | ||
|
||
default List<Measure> getMeasures(List<String> measureIds, List<String> measureIdentifiers, | ||
List<CanonicalType> measureCanonicals) { | ||
boolean hasMeasureIds = measureIds != null && !measureIds.isEmpty(); | ||
boolean hasMeasureIdentifiers = measureIdentifiers != null && !measureIdentifiers.isEmpty(); | ||
boolean hasMeasureUrls = measureCanonicals != null && !measureCanonicals.isEmpty(); | ||
if (!hasMeasureIds && !hasMeasureIdentifiers && !hasMeasureUrls) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
List<Measure> measureList = new ArrayList<>(); | ||
|
||
if (hasMeasureIds) { | ||
measureList.addAll(search(Measure.class, Searches.byIds(measureIds)).getAllResourcesTyped()); | ||
} | ||
|
||
// TODO: implement searching by measure identifiers | ||
if (hasMeasureIdentifiers) { | ||
throw new NotImplementedException(); | ||
// measureList.addAll(search(Measure.class, | ||
// Searches.byIdentifiers(measureIdentifiers)).getAllResourcesTyped()); | ||
} | ||
|
||
if (hasMeasureUrls) { | ||
measureList.addAll(search(Measure.class, Searches.byCanonicals(measureCanonicals)).getAllResourcesTyped()); | ||
} | ||
|
||
Map<String, Measure> result = new HashMap<>(); | ||
measureList.forEach(measure -> result.putIfAbsent(measure.getUrl(), measure)); | ||
|
||
return new ArrayList<>(result.values()); | ||
} | ||
|
||
// TODO: replace this with version from the evaluator? | ||
default List<Patient> getPatientListFromSubject(String subject) { | ||
if (subject.startsWith("Patient/")) { | ||
return Collections.singletonList(ensurePatient(subject)); | ||
} else if (subject.startsWith("Group/")) { | ||
return getPatientListFromGroup(subject); | ||
} | ||
|
||
ourLog.info("Subject member was not a Patient or a Group, so skipping. \n{}", subject); | ||
return Collections.emptyList(); | ||
} | ||
|
||
// TODO: replace this with version from the evaluator? | ||
default List<Patient> getPatientListFromGroup(String subjectGroupId) { | ||
List<Patient> patientList = new ArrayList<>(); | ||
|
||
Group group = read(newId(subjectGroupId)); | ||
if (group == null) { | ||
throw new IllegalArgumentException("Could not find Group: " + subjectGroupId); | ||
} | ||
|
||
group.getMember().forEach(member -> { | ||
Reference reference = member.getEntity(); | ||
if (reference.getReferenceElement().getResourceType().equals("Patient")) { | ||
Patient patient = ensurePatient(reference.getReference()); | ||
patientList.add(patient); | ||
} else if (reference.getReferenceElement().getResourceType().equals("Group")) { | ||
patientList.addAll(getPatientListFromGroup(reference.getReference())); | ||
} else { | ||
ourLog.info("Group member was not a Patient or a Group, so skipping. \n{}", reference.getReference()); | ||
} | ||
}); | ||
|
||
return patientList; | ||
} | ||
|
||
// TODO: replace this with version from the evaluator? | ||
default Patient ensurePatient(String patientRef) { | ||
Patient patient = read(newId(patientRef)); | ||
if (patient == null) { | ||
throw new IllegalArgumentException("Could not find Patient: " + patientRef); | ||
} | ||
|
||
return patient; | ||
} | ||
} |
Oops, something went wrong.