Search in sources :

Example 91 with Rule

use of org.hl7.fhir.utilities.xml.SchematronWriter.Rule in project org.hl7.fhir.core by hapifhir.

the class ValidationTests method test.

@SuppressWarnings("deprecation")
@Test
public void test() throws Exception {
    CacheVerificationLogger logger = new CacheVerificationLogger();
    long setup = System.nanoTime();
    this.name = name;
    System.out.println("---- " + name + " ----------------------------------------------------------------");
    System.out.println("** Core: ");
    String txLog = null;
    if (content.has("txLog")) {
        txLog = content.get("txLog").getAsString();
    }
    version = "5.0";
    List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
    if (content.has("version")) {
        version = content.get("version").getAsString();
    }
    version = VersionUtilities.getMajMin(version);
    if (!ve.containsKey(version)) {
        if (version.startsWith("5.0"))
            ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r5.core#4.5.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R5, true, "4.5.0"));
        else if (version.startsWith("4.3"))
            ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r4b.core#4.3.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R4B, true, "4.3.0"));
        else if (version.startsWith("4.0"))
            ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R4, true, "4.0.1"));
        else if (version.startsWith("3.0"))
            ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", ValidationEngineTests.DEF_TX, txLog, FhirPublication.STU3, true, "3.0.2"));
        else if (version.startsWith("1.4"))
            ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.DSTU2016May, true, "1.4.0"));
        else if (version.startsWith("1.0"))
            ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", ValidationEngineTests.DEF_TX, txLog, FhirPublication.DSTU2, true, "1.0.2"));
        else
            throw new Exception("unknown version " + version);
    }
    vCurr = ve.get(version);
    vCurr.getContext().getTxClient().setLogger(logger);
    igLoader = new IgLoader(vCurr.getPcm(), vCurr.getContext(), vCurr.getVersion(), true);
    if (TestingUtilities.fcontexts == null) {
        TestingUtilities.fcontexts = new HashMap<>();
    }
    TestingUtilities.fcontexts.put(version, vCurr.getContext());
    if (content.has("use-test") && !content.get("use-test").getAsBoolean())
        return;
    byte[] testCaseContent = TestingUtilities.loadTestResource("validator", JSONUtil.str(content, "file")).getBytes(StandardCharsets.UTF_8);
    // load and process content
    FhirFormat fmt = determineFormat(content, testCaseContent);
    InstanceValidator val = vCurr.getValidator(fmt);
    val.setWantCheckSnapshotUnchanged(true);
    val.getContext().setClientRetryCount(4);
    val.setDebug(false);
    if (content.has("fetcher") && "standalone".equals(JSONUtil.str(content, "fetcher"))) {
        val.setFetcher(vCurr);
        vCurr.setFetcher(new StandAloneValidatorFetcher(vCurr.getPcm(), vCurr.getContext(), vCurr));
    } else {
        val.setFetcher(this);
    }
    val.setPolicyAdvisor(this);
    if (content.has("allowed-extension-domain"))
        val.getExtensionDomains().add(content.get("allowed-extension-domain").getAsString());
    if (content.has("allowed-extension-domains"))
        for (JsonElement a : content.getAsJsonArray("allowed-extension-domains")) val.getExtensionDomains().add(a.getAsString());
    if (content.has("language"))
        val.setValidationLanguage(content.get("language").getAsString());
    else
        val.setValidationLanguage(null);
    if (content.has("default-version")) {
        val.setBaseOptions(val.getBaseOptions().setVersionFlexible(content.get("default-version").getAsBoolean()));
    } else {
        val.setBaseOptions(val.getBaseOptions().setVersionFlexible(false));
    }
    if (content.has("packages")) {
        for (JsonElement e : content.getAsJsonArray("packages")) {
            String n = e.getAsString();
            InputStream cnt = n.endsWith(".tgz") ? TestingUtilities.loadTestResourceStream("validator", n) : null;
            if (cnt != null) {
                igLoader.loadPackage(NpmPackage.fromPackage(cnt));
            } else {
                igLoader.loadIg(vCurr.getIgs(), vCurr.getBinaries(), n, true);
            }
        }
    }
    if (content.has("crumb-trail")) {
        val.setCrumbTrails(content.get("crumb-trail").getAsBoolean());
    }
    if (content.has("supporting")) {
        for (JsonElement e : content.getAsJsonArray("supporting")) {
            String filename = e.getAsString();
            String contents = TestingUtilities.loadTestResource("validator", filename);
            CanonicalResource mr = (CanonicalResource) loadResource(filename, contents);
            val.getContext().cacheResource(mr);
            if (mr instanceof ImplementationGuide) {
                val.getImplementationGuides().add((ImplementationGuide) mr);
            }
        }
    }
    val.getBundleValidationRules().clear();
    if (content.has("bundle-param")) {
        val.getBundleValidationRules().add(new BundleValidationRule(content.getAsJsonObject("bundle-param").get("rule").getAsString(), content.getAsJsonObject("bundle-param").get("profile").getAsString()));
    }
    if (content.has("profiles")) {
        for (JsonElement je : content.getAsJsonArray("profiles")) {
            String filename = je.getAsString();
            String contents = TestingUtilities.loadTestResource("validator", filename);
            StructureDefinition sd = loadProfile(filename, contents, messages, val.isDebug());
            val.getContext().cacheResource(sd);
        }
    }
    List<ValidationMessage> errors = new ArrayList<ValidationMessage>();
    if (content.getAsJsonObject("java").has("debug")) {
        val.setDebug(content.getAsJsonObject("java").get("debug").getAsBoolean());
    } else {
        val.setDebug(false);
    }
    if (content.has("best-practice")) {
        val.setBestPracticeWarningLevel(BestPracticeWarningLevel.valueOf(content.get("best-practice").getAsString()));
    }
    if (content.has("examples")) {
        val.setAllowExamples(content.get("examples").getAsBoolean());
    } else {
        val.setAllowExamples(true);
    }
    if (content.has("security-checks")) {
        val.setSecurityChecks(content.get("security-checks").getAsBoolean());
    }
    if (content.has("logical") == false) {
        val.setAssumeValidRestReferences(content.has("assumeValidRestReferences") ? content.get("assumeValidRestReferences").getAsBoolean() : false);
        System.out.println(String.format("Start Validating (%d to set up)", (System.nanoTime() - setup) / 1000000));
        val.validate(null, errors, new ByteArrayInputStream(testCaseContent), fmt);
        System.out.println(val.reportTimes());
        checkOutcomes(errors, content, null, name);
    }
    if (content.has("profile")) {
        System.out.print("** Profile: ");
        JsonObject profile = content.getAsJsonObject("profile");
        if (profile.has("packages")) {
            for (JsonElement e : profile.getAsJsonArray("packages")) {
                igLoader.loadIg(vCurr.getIgs(), vCurr.getBinaries(), e.getAsString(), true);
            }
        }
        if (profile.getAsJsonObject("java").has("debug")) {
            val.setDebug(profile.getAsJsonObject("java").get("debug").getAsBoolean());
        }
        if (profile.has("supporting")) {
            for (JsonElement e : profile.getAsJsonArray("supporting")) {
                String filename = e.getAsString();
                String contents = TestingUtilities.loadTestResource("validator", filename);
                CanonicalResource mr = (CanonicalResource) loadResource(filename, contents);
                val.getContext().cacheResource(mr);
                if (mr instanceof ImplementationGuide) {
                    val.getImplementationGuides().add((ImplementationGuide) mr);
                }
            }
        }
        StructureDefinition sd = null;
        String filename = profile.get("source").getAsString();
        if (Utilities.isAbsoluteUrl(filename)) {
            sd = val.getContext().fetchResource(StructureDefinition.class, filename);
        } else {
            String contents = TestingUtilities.loadTestResource("validator", filename);
            System.out.println("Name: " + name + " - profile : " + profile.get("source").getAsString());
            version = content.has("version") ? content.get("version").getAsString() : Constants.VERSION;
            sd = loadProfile(filename, contents, messages, val.isDebug());
            val.getContext().cacheResource(sd);
        }
        val.setAssumeValidRestReferences(profile.has("assumeValidRestReferences") ? profile.get("assumeValidRestReferences").getAsBoolean() : false);
        List<ValidationMessage> errorsProfile = new ArrayList<ValidationMessage>();
        val.validate(null, errorsProfile, new ByteArrayInputStream(testCaseContent), fmt, asSdList(sd));
        System.out.println(val.reportTimes());
        checkOutcomes(errorsProfile, profile, filename, name);
    }
    if (content.has("logical")) {
        System.out.print("** Logical: ");
        JsonObject logical = content.getAsJsonObject("logical");
        if (logical.has("supporting")) {
            for (JsonElement e : logical.getAsJsonArray("supporting")) {
                String filename = e.getAsString();
                String contents = TestingUtilities.loadTestResource("validator", filename);
                CanonicalResource mr = (CanonicalResource) loadResource(filename, contents);
                if (mr instanceof StructureDefinition) {
                    val.getContext().generateSnapshot((StructureDefinition) mr, true);
                }
                val.getContext().cacheResource(mr);
            }
        }
        if (logical.has("packages")) {
            for (JsonElement e : logical.getAsJsonArray("packages")) {
                igLoader.loadIg(vCurr.getIgs(), vCurr.getBinaries(), e.getAsString(), true);
            }
        }
        List<ValidationMessage> errorsLogical = new ArrayList<ValidationMessage>();
        Element le = val.validate(null, errorsLogical, new ByteArrayInputStream(testCaseContent), fmt);
        if (logical.has("expressions")) {
            FHIRPathEngine fp = new FHIRPathEngine(val.getContext());
            for (JsonElement e : logical.getAsJsonArray("expressions")) {
                String exp = e.getAsString();
                Assert.assertTrue(fp.evaluateToBoolean(null, le, le, le, fp.parse(exp)));
            }
        }
        checkOutcomes(errorsLogical, logical, "logical", name);
    }
    logger.verifyHasNoRequests();
}
Also used : IgLoader(org.hl7.fhir.validation.IgLoader) BundleValidationRule(org.hl7.fhir.r5.utils.validation.BundleValidationRule) InstanceValidator(org.hl7.fhir.validation.instance.InstanceValidator) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) FHIRPathEngine(org.hl7.fhir.r5.utils.FHIRPathEngine) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) JsonElement(com.google.gson.JsonElement) Element(org.hl7.fhir.r5.elementmodel.Element) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) FhirFormat(org.hl7.fhir.r5.elementmodel.Manager.FhirFormat) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ByteArrayInputStream(java.io.ByteArrayInputStream) CacheVerificationLogger(org.hl7.fhir.utilities.tests.CacheVerificationLogger) JsonElement(com.google.gson.JsonElement) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) StandAloneValidatorFetcher(org.hl7.fhir.validation.cli.services.StandAloneValidatorFetcher) Test(org.junit.Test)

Example 92 with Rule

use of org.hl7.fhir.utilities.xml.SchematronWriter.Rule in project org.hl7.fhir.core by hapifhir.

the class SnapShotGenerationXTests method test.

@ParameterizedTest(name = "{index}: file {0}")
@MethodSource("data")
public void test(String id, TestDetails test, SnapShotGenerationTestsContext context) throws Exception {
    version = test.version;
    this.context = context;
    if (fp == null)
        fp = new FHIRPathEngine(UtilitiesXTests.context(version));
    fp.setHostServices(context);
    messages = new ArrayList<ValidationMessage>();
    if (test.isFail()) {
        try {
            if (test.isGen())
                testGen(true, test);
            else
                testSort(test);
            Assertions.assertTrue(false, "Should have failed");
        } catch (Throwable e) {
            System.out.println("Error running test: " + e.getMessage());
            if (!Utilities.noString(test.regex)) {
                Assertions.assertTrue(e.getMessage().matches(test.regex), "correct error message");
            } else if ("Should have failed".equals(e.getMessage())) {
                throw e;
            } else {
                Assertions.assertTrue(true, "all ok");
            }
        }
    } else if (test.isGen())
        testGen(false, test);
    else
        testSort(test);
    for (Rule r : test.getRules()) {
        StructureDefinition sdn = new StructureDefinition();
        boolean ok = fp.evaluateToBoolean(sdn, sdn, sdn, r.expression);
        Assertions.assertTrue(ok, r.description);
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) FHIRPathEngine(org.hl7.fhir.r5.utils.FHIRPathEngine) TypeDerivationRule(org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 93 with Rule

use of org.hl7.fhir.utilities.xml.SchematronWriter.Rule in project redmatch by aehrc.

the class RedmatchApi method exportAll.

/**
 * Runs an operation on all the Redmatch rule documents found in the base folder.
 *
 * @param baseFolder The folder that contains the Redmatch rule documents , one or more schemas referenced by the
 *                   rules and a redmatch-config.yaml file with source server details.
 * @param progressReporter An object used to report progress. Can be null.
 * @param cancelToken Used to check if the user has cancelled the operation.
 * @return Map of diagnostic messages. Key is file where error happened.
 */
public List<Diagnostic> exportAll(@NotNull File baseFolder, ProgressReporter progressReporter, CancelChecker cancelToken) {
    if (!baseFolder.canRead() || !baseFolder.canWrite()) {
        return List.of(new Diagnostic(zeroZero, "Unable to read or write on the base folder.", DiagnosticSeverity.Error, "API"));
    }
    // Get .rdm files
    List<File> rdmFiles;
    try (Stream<Path> walk = Files.walk(baseFolder.toPath())) {
        rdmFiles = walk.filter(p -> !Files.isDirectory(p)).map(Path::toFile).filter(f -> f.getName().endsWith(".rdm")).collect(Collectors.toList());
    } catch (IOException e) {
        return List.of(new Diagnostic(zeroZero, "Unexpected I/O error: " + e.getLocalizedMessage(), DiagnosticSeverity.Error, "API"));
    }
    try {
        List<Diagnostic> diagnostics = new ArrayList<>();
        Map<String, DomainResource> resourcesMap = new HashMap<>();
        for (File rdmFile : rdmFiles) {
            Pair<Map<String, DomainResource>, List<Diagnostic>> data = transform(rdmFile, progressReporter, cancelToken);
            resourcesMap.putAll(data.getValue0());
            diagnostics.addAll(data.getValue1());
        }
        // Group resources by type
        final Map<String, List<DomainResource>> grouped = new HashMap<>();
        for (String key : resourcesMap.keySet()) {
            DomainResource dr = resourcesMap.get(key);
            String resourceType = dr.getResourceType().toString();
            List<DomainResource> list = grouped.computeIfAbsent(resourceType, k -> new ArrayList<>());
            list.add(dr);
        }
        Path outputFolder = createOutputFolder(baseFolder).toPath();
        save(grouped, outputFolder, progressReporter, cancelToken);
        return diagnostics;
    } catch (Exception e) {
        log.error(e);
        return List.of(new Diagnostic(zeroZero, "Could not complete transformation:" + e.getLocalizedMessage(), DiagnosticSeverity.Error, "API"));
    }
}
Also used : Path(java.nio.file.Path) DomainResource(org.hl7.fhir.r4.model.DomainResource) Diagnostic(org.eclipse.lsp4j.Diagnostic)

Example 94 with Rule

use of org.hl7.fhir.utilities.xml.SchematronWriter.Rule 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;
}
Also used : CqlResultsForCard(org.hl7.davinci.endpoint.components.CardBuilder.CqlResultsForCard) AlternativeTherapy(org.cdshooks.AlternativeTherapy) DrugInteraction(org.cdshooks.DrugInteraction) CoverageRequirements(org.cdshooks.CoverageRequirements) JSONObject(org.json.simple.JSONObject) Code(org.opencds.cqf.cql.engine.runtime.Code) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException)

Example 95 with Rule

use of org.hl7.fhir.utilities.xml.SchematronWriter.Rule 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;
}
Also used : ArrayList(java.util.ArrayList) RuleMapping(org.hl7.davinci.endpoint.database.RuleMapping)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)76 ArrayList (java.util.ArrayList)46 Element (org.hl7.fhir.r5.elementmodel.Element)38 IOException (java.io.IOException)28 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)26 NodeStack (org.hl7.fhir.validation.instance.utils.NodeStack)23 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)20 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)20 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)19 IndexedElement (org.hl7.fhir.validation.instance.utils.IndexedElement)17 NotImplementedException (org.apache.commons.lang3.NotImplementedException)16 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)14 FHIRLexerException (org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException)14 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)13 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)13 NamedElement (org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement)13 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)13 ValueSet (org.hl7.fhir.r5.model.ValueSet)13 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)13 SpecialElement (org.hl7.fhir.r5.elementmodel.Element.SpecialElement)12