use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class R4FileSystemFhirTerminologyProviderTest method inOperationReturnsTrueWithCodeOnly.
@Test
public void inOperationReturnsTrueWithCodeOnly() throws Exception {
ValueSetInfo info = new ValueSetInfo();
info.setId(setId);
Code code = new Code();
code.setCode(TEST_CODE);
boolean result = provider.in(code, info);
assertTrue(result);
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class R4FileSystemFhirTerminologyProviderTest method inOperationReturnsFalseWithBadCodeSystem.
@Test
public void inOperationReturnsFalseWithBadCodeSystem() throws Exception {
ValueSetInfo info = new ValueSetInfo();
info.setId(setId);
Code code = new Code();
code.setSystem("bad system");
code.setCode(TEST_CODE);
code.setDisplay(TEST_DISPLAY);
boolean result = provider.in(code, info);
assertFalse(result);
}
use of org.opencds.cqf.cql.engine.runtime.Code in project CRD by HL7-DaVinci.
the class OrderSignService method executeCqlAndGetRelevantResults.
protected CqlResultsForCard executeCqlAndGetRelevantResults(Context context, String topic) {
CqlResultsForCard results = new CqlResultsForCard();
results.setRuleApplies((Boolean) evaluateStatement("RULE_APPLIES", context));
if (!results.ruleApplies()) {
logger.warn("rule does not apply");
return results;
}
CoverageRequirements coverageRequirements = new CoverageRequirements();
coverageRequirements.setApplies(true);
String humanReadableTopic = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(topic), ' ');
coverageRequirements.setInfoLink(evaluateStatement("RESULT_InfoLink", context).toString()).setPriorAuthRequired((Boolean) evaluateStatement("PRIORAUTH_REQUIRED", context)).setDocumentationRequired((Boolean) evaluateStatement("DOCUMENTATION_REQUIRED", context));
// if prior auth, supercede the documentation required
if (coverageRequirements.isPriorAuthRequired()) {
logger.info("Prior Auth Required");
coverageRequirements.setSummary(humanReadableTopic + ": Prior Authorization required.").setDetails("Prior Authorization required, follow the attached link for information.");
// check if prior auth is automatically approved
if (evaluateStatement("APPROVE_PRIORAUTH", context) != null) {
coverageRequirements.setPriorAuthApproved((Boolean) evaluateStatement("APPROVE_PRIORAUTH", context));
if (coverageRequirements.isPriorAuthApproved()) {
coverageRequirements.generatePriorAuthId();
logger.info("Prior Auth Approved: " + coverageRequirements.getPriorAuthId());
coverageRequirements.setSummary(humanReadableTopic + ": Prior Authorization approved.").setDetails("Prior Authorization approved, ID is " + coverageRequirements.getPriorAuthId());
}
}
} else if (coverageRequirements.isDocumentationRequired()) {
logger.info("Documentation Required");
coverageRequirements.setSummary(humanReadableTopic + ": Documentation Required.").setDetails("Documentation Required, please complete form via Smart App link.");
} else {
logger.info("No Prior Auth or Documentation Required");
coverageRequirements.setSummary(humanReadableTopic + ": No Prior Authorization required.").setDetails("No Prior Authorization required for " + humanReadableTopic + ".");
}
if (evaluateStatement("RESULT_requestId", context) != null) {
results.setRequest((IBaseResource) evaluateStatement("RESULT_requestId", context));
coverageRequirements.setRequestId(JSONObject.escape(fhirComponents.getFhirContext().newJsonParser().encodeResourceToString(results.getRequest())));
}
// setup the alternative therapy information
AlternativeTherapy alternativeTherapy = new AlternativeTherapy();
alternativeTherapy.setApplies(false);
if (evaluateStatement("RESULT_dispense", context) != null) {
results.setRequest((IBaseResource) evaluateStatement("RESULT_dispense", context));
coverageRequirements.setRequestId(JSONObject.escape(fhirComponents.getFhirContext().newJsonParser().encodeResourceToString(results.getRequest())));
// only display the dispense form for MedicationDispense request
try {
if (evaluateStatement("RESULT_QuestionnaireDispenseUri", context) != null) {
coverageRequirements.setQuestionnaireDispenseUri(evaluateStatement("RESULT_QuestionnaireDispenseUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No Dispense questionnaire defined");
}
} else // not a MedicationDispense
{
if (evaluateStatement("RESULT_QuestionnaireOrderUri", context) != null) {
coverageRequirements.setQuestionnaireOrderUri(evaluateStatement("RESULT_QuestionnaireOrderUri", context).toString());
}
try {
if (evaluateStatement("RESULT_QuestionnaireFaceToFaceUri", context) != null) {
coverageRequirements.setQuestionnaireFaceToFaceUri(evaluateStatement("RESULT_QuestionnaireFaceToFaceUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No face to face questionnaire defined");
}
try {
if (evaluateStatement("RESULT_QuestionnaireLabUri", context) != null) {
coverageRequirements.setQuestionnaireLabUri(evaluateStatement("RESULT_QuestionnaireLabUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No Lab questionnaire defined");
}
try {
if (evaluateStatement("RESULT_QuestionnaireProgressNoteUri", context) != null) {
coverageRequirements.setQuestionnaireProgressNoteUri(evaluateStatement("RESULT_QuestionnaireProgressNoteUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No Progress note questionnaire defined");
}
try {
if (evaluateStatement("RESULT_QuestionnairePlanOfCareUri", context) != null) {
coverageRequirements.setQuestionnairePlanOfCareUri(evaluateStatement("RESULT_QuestionnairePlanOfCareUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No plan of care questionnaire defined");
}
try {
if (evaluateStatement("RESULT_QuestionnairePARequestUri", context) != null) {
coverageRequirements.setQuestionnairePARequestUri(evaluateStatement("RESULT_QuestionnairePARequestUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No PA Request questionnaire defined");
}
try {
if (evaluateStatement("RESULT_QuestionnaireAdditionalUri", context) != null) {
coverageRequirements.setQuestionnaireAdditionalUri(evaluateStatement("RESULT_QuestionnaireAdditionalUri", context).toString());
}
} catch (Exception e) {
logger.info("-- No additional questionnaire defined");
}
// process the alternative therapies
try {
if (evaluateStatement("ALTERNATIVE_THERAPY", context) != null) {
Object ac = evaluateStatement("ALTERNATIVE_THERAPY", context);
Code code = (Code) ac;
logger.info("alternate therapy suggested: " + code.getDisplay() + " (" + code.getCode() + " / " + ShortNameMaps.CODE_SYSTEM_SHORT_NAME_TO_FULL_NAME.inverse().get(code.getSystem()).toUpperCase() + ")");
alternativeTherapy.setApplies(true).setCode(code.getCode()).setSystem(code.getSystem()).setDisplay(code.getDisplay());
}
} catch (Exception e) {
logger.info("-- No alternative therapy defined");
}
}
results.setCoverageRequirements(coverageRequirements);
results.setAlternativeTherapy(alternativeTherapy);
// add empty drug interaction
DrugInteraction drugInteraction = new DrugInteraction();
drugInteraction.setApplies(false);
results.setDrugInteraction(drugInteraction);
return results;
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class R4RestFhirTerminologyProvider method expand.
/**
* This is a small patch to the OSS implementation to use a GET request vs. a
* POST request with { "resource": "Parameters" } as the body in order to bypass
* IBM FHIR failing to parse the empty parameters object.
*/
@Override
public Iterable<Code> expand(ValueSetInfo valueSet) throws ResourceNotFoundException {
if (resolveByUrl(valueSet) == null) {
return Collections.emptyList();
}
Parameters respParam = fhirClient.operation().onInstance(new IdType("ValueSet", valueSet.getId())).named("expand").withNoParameters(Parameters.class).useHttpGet().execute();
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
List<Code> codes = new ArrayList<>();
for (ValueSet.ValueSetExpansionContainsComponent codeInfo : expanded.getExpansion().getContains()) {
Code nextCode = new Code().withCode(codeInfo.getCode()).withSystem(codeInfo.getSystem()).withVersion(codeInfo.getVersion()).withDisplay(codeInfo.getDisplay());
codes.add(nextCode);
}
return codes;
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class MeasureSupplementalDataEvaluationTest method testPopulateSex_badCodeString.
@Test
public void testPopulateSex_badCodeString() {
Code badCode = getMaleCode();
badCode.setCode(null);
Map<String, Map<String, Integer>> sdeAccumulators = getSexSDEAccumulatorsWithCode(badCode);
assertTrue(sdeAccumulators.isEmpty());
}
Aggregations