use of org.hl7.davinci.endpoint.cdshooks.services.crd.r4.FhirBundleProcessor 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.cdshooks.services.crd.r4.FhirBundleProcessor in project CRD by HL7-DaVinci.
the class OrderSelectService method createCqlExecutionContexts.
@Override
public List<CoverageRequirementRuleResult> createCqlExecutionContexts(OrderSelectRequest orderSelectRequest, FileStore fileStore, String baseUrl) {
List<String> selections = Arrays.asList(orderSelectRequest.getContext().getSelections());
FhirBundleProcessor fhirBundleProcessor = new FhirBundleProcessor(fileStore, baseUrl, selections);
CrdPrefetch prefetch = orderSelectRequest.getPrefetch();
fhirBundleProcessor.processOrderSelectMedicationStatements(prefetch.getMedicationRequestBundle(), prefetch.getMedicationStatementBundle());
List<CoverageRequirementRuleResult> results = fhirBundleProcessor.getResults();
if (results.isEmpty()) {
throw RequestIncompleteException.NoSupportedBundlesFound();
}
return results;
}
use of org.hl7.davinci.endpoint.cdshooks.services.crd.r4.FhirBundleProcessor 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());
}
}
}
}
use of org.hl7.davinci.endpoint.cdshooks.services.crd.r4.FhirBundleProcessor in project CRD by HL7-DaVinci.
the class OrderSignService method createCqlExecutionContexts.
@Override
public List<CoverageRequirementRuleResult> createCqlExecutionContexts(OrderSignRequest orderSignRequest, FileStore fileStore, String baseUrl) {
FhirBundleProcessor fhirBundleProcessor = new FhirBundleProcessor(fileStore, baseUrl);
CrdPrefetch prefetch = orderSignRequest.getPrefetch();
fhirBundleProcessor.processDeviceRequests(prefetch.getDeviceRequestBundle());
fhirBundleProcessor.processMedicationRequests(prefetch.getMedicationRequestBundle());
fhirBundleProcessor.processServiceRequests(prefetch.getServiceRequestBundle());
fhirBundleProcessor.processMedicationDispenses(prefetch.getMedicationDispenseBundle());
List<CoverageRequirementRuleResult> results = fhirBundleProcessor.getResults();
if (results.isEmpty()) {
throw RequestIncompleteException.NoSupportedBundlesFound();
}
return results;
}
use of org.hl7.davinci.endpoint.cdshooks.services.crd.r4.FhirBundleProcessor in project CRD by HL7-DaVinci.
the class QuestionnairePackageOperation method createTopicList.
private List<String> createTopicList(FhirBundleProcessor fhirBundleProcessor) {
List<String> topics = new ArrayList<>();
List<CoverageRequirementRuleResult> results = fhirBundleProcessor.getResults();
for (CoverageRequirementRuleResult result : results) {
// add topic to the list if not already contained
if (!topics.contains(result.getTopic())) {
topics.add(result.getTopic());
}
}
return topics;
}
Aggregations