use of org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria in project CRD by HL7-DaVinci.
the class FhirBundleProcessor method createCriteriaList.
private List<CoverageRequirementRuleCriteria> createCriteriaList(CodeableConcept codeableConcept, List<Reference> insurance, List<Organization> payorList) {
try {
List<Coding> codings = codeableConcept.getCoding();
if (codings.size() > 0) {
logger.info("r4/FhirBundleProcessor::createCriteriaList: code[0]: " + codings.get(0).getCode() + " - " + codings.get(0).getSystem());
} else {
logger.info("r4/FhirBundleProcessor::createCriteriaList: empty codes list!");
}
List<Organization> payors = new ArrayList<>();
if (insurance != null) {
List<Coverage> coverages = insurance.stream().map(reference -> (Coverage) reference.getResource()).collect(Collectors.toList());
// Remove null coverages that may not have resolved.
coverages = coverages.stream().filter(coverage -> coverage != null).collect(Collectors.toList());
payors = Utilities.getPayors(coverages);
} else if (payorList != null) {
payors = payorList;
}
if (payors.size() > 0) {
logger.info("r4/FhirBundleProcessor::createCriteriaList: payer[0]: " + payors.get(0).getName());
} else {
// default to CMS if no payer was provided
logger.info("r4/FhirBundleProcessor::createCriteriaList: empty payers list, working around by adding CMS!");
Organization org = new Organization().setName("Centers for Medicare and Medicaid Services");
// how to get ID
org.setId("75f39025-65db-43c8-9127-693cdf75e712");
payors.add(org);
// remove the exception to use CMS if no payer is provided
// JIRA ticket https://jira.mitre.org/browse/DMEERX-894
// throw new RequestIncompleteException("No Payer found in coverage resource, cannot find documentation.");
}
List<CoverageRequirementRuleCriteria> criteriaList = CoverageRequirementRuleCriteria.createQueriesFromR4(codings, payors);
return criteriaList;
} catch (RequestIncompleteException e) {
// rethrow incomplete request exceptions
throw e;
} catch (Exception e) {
// catch all remaining exceptions
System.out.println(e);
throw new RequestIncompleteException("Unable to parse list of codes, codesystems, and payors from a device request.");
}
}
use of org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria in project CRD by HL7-DaVinci.
the class RuleFinder method findRules.
/**
* Find and retern the relevant coverage rules in the database.
* @param criteria The search criteria object
* @return List of matching RuleMapping entries
*/
public List<RuleMapping> findRules(CoverageRequirementRuleCriteria criteria) {
logger.info("RuleFinder::findRules(" + criteria.getQueryString() + ")");
List<RuleMapping> ruleList = new ArrayList<>();
if (ruleMappingRepository == null) {
logger.warn("RuleFinder::findRules: the ruleMappingRepository is null");
return ruleList;
}
for (RuleMapping rule : ruleMappingRepository.findRules(criteria)) {
ruleList.add(rule);
}
if (ruleList.size() == 0) {
logger.info("RuleFinder::findRules() returned no results for query: " + criteria.toString());
}
return ruleList;
}
use of org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria in project CRD by HL7-DaVinci.
the class FhirBundleProcessor method buildExecutionContexts.
private void buildExecutionContexts(List<CoverageRequirementRuleCriteria> criteriaList, HashMap<String, Resource> cqlParams) {
for (CoverageRequirementRuleCriteria criteria : criteriaList) {
logger.info("FhirBundleProcessor::buildExecutionContexts() criteria: " + criteria.toString());
List<RuleMapping> rules = fileStore.findRules(criteria);
for (RuleMapping rule : rules) {
CoverageRequirementRuleResult result = new CoverageRequirementRuleResult();
result.setCriteria(criteria).setTopic(rule.getTopic());
try {
logger.info("FhirBundleProcessor::buildExecutionContexts() found rule topic: " + rule.getTopic());
// get the CqlRule
CqlRule cqlRule = fileStore.getCqlRule(rule.getTopic(), rule.getFhirVersion());
result.setContext(CqlExecutionContextBuilder.getExecutionContext(cqlRule, cqlParams, baseUrl));
results.add(result);
} catch (Exception e) {
logger.info("r4/FhirBundleProcessor::buildExecutionContexts: failed processing cql bundle: " + e.getMessage());
}
}
}
}
Aggregations