Search in sources :

Example 96 with Expression

use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.

the class Params method loadCliContext.

/**
 * TODO Don't do this all in one for loop. Use the above methods.
 */
public static CliContext loadCliContext(String[] args) throws Exception {
    CliContext cliContext = new CliContext();
    // load the parameters - so order doesn't matter
    for (int i = 0; i < args.length; i++) {
        if (args[i].equals(VERSION)) {
            cliContext.setSv(VersionUtilities.getCurrentPackageVersion(args[++i]));
        } else if (args[i].equals(OUTPUT)) {
            if (i + 1 == args.length)
                throw new Error("Specified -output without indicating output file");
            else
                cliContext.setOutput(args[++i]);
        } else if (args[i].equals(HTML_OUTPUT)) {
            if (i + 1 == args.length)
                throw new Error("Specified -html-output without indicating output file");
            else
                cliContext.setHtmlOutput(args[++i]);
        } else if (args[i].equals(PROXY)) {
            // ignore next parameter
            i++;
        } else if (args[i].equals(PROXY_AUTH)) {
            i++;
        } else if (args[i].equals(PROFILE)) {
            String p = null;
            if (i + 1 == args.length) {
                throw new Error("Specified -profile without indicating profile source");
            } else {
                p = args[++i];
                cliContext.addProfile(p);
            }
        } else if (args[i].equals(BUNDLE)) {
            String p = null;
            String r = null;
            if (i + 1 == args.length) {
                throw new Error("Specified -profile without indicating bundle rule ");
            } else {
                r = args[++i];
            }
            if (i + 1 == args.length) {
                throw new Error("Specified -profile without indicating profile source");
            } else {
                p = args[++i];
            }
            cliContext.getBundleValidationRules().add(new BundleValidationRule(r, p));
        } else if (args[i].equals(QUESTIONNAIRE)) {
            if (i + 1 == args.length)
                throw new Error("Specified -questionnaire without indicating questionnaire mode");
            else {
                String q = args[++i];
                cliContext.setQuestionnaireMode(QuestionnaireMode.fromCode(q));
            }
        } else if (args[i].equals(LEVEL)) {
            if (i + 1 == args.length)
                throw new Error("Specified -level without indicating level mode");
            else {
                String q = args[++i];
                cliContext.setLevel(ValidationLevel.fromCode(q));
            }
        } else if (args[i].equals(NATIVE)) {
            cliContext.setDoNative(true);
        } else if (args[i].equals(ASSUME_VALID_REST_REF)) {
            cliContext.setAssumeValidRestReferences(true);
        } else if (args[i].equals(DEBUG)) {
            cliContext.setDoDebug(true);
        } else if (args[i].equals(SCT)) {
            cliContext.setSnomedCT(args[++i]);
        } else if (args[i].equals(RECURSE)) {
            cliContext.setRecursive(true);
        } else if (args[i].equals(SHOW_MESSAGES_FROM_REFERENCES)) {
            cliContext.setShowMessagesFromReferences(true);
        } else if (args[i].equals(LOCALE)) {
            if (i + 1 == args.length) {
                throw new Error("Specified -locale without indicating locale");
            } else {
                cliContext.setLocale(new Locale(args[++i]));
            }
        } else if (args[i].equals(EXTENSIONS)) {
            cliContext.getExtensions().add(args[++i]);
        } else if (args[i].equals(NO_INTERNAL_CACHING)) {
            cliContext.setNoInternalCaching(true);
        } else if (args[i].equals(NO_EXTENSIBLE_BINDING_WARNINGS)) {
            cliContext.setNoExtensibleBindingMessages(true);
        } else if (args[i].equals(NO_UNICODE_BIDI_CONTROL_CHARS)) {
            cliContext.setNoUnicodeBiDiControlChars(true);
        } else if (args[i].equals(NO_INVARIANTS)) {
            cliContext.setNoInvariants(true);
        } else if (args[i].equals(WANT_INVARIANTS_IN_MESSAGES)) {
            cliContext.setWantInvariantsInMessages(true);
        } else if (args[i].equals(HINT_ABOUT_NON_MUST_SUPPORT)) {
            cliContext.setHintAboutNonMustSupport(true);
        } else if (args[i].equals(TO_VERSION)) {
            cliContext.setTargetVer(args[++i]);
            cliContext.setMode(EngineMode.VERSION);
        } else if (args[i].equals(DO_NATIVE)) {
            cliContext.setCanDoNative(true);
        } else if (args[i].equals(NO_NATIVE)) {
            cliContext.setCanDoNative(false);
        } else if (args[i].equals(TRANSFORM)) {
            cliContext.setMap(args[++i]);
            cliContext.setMode(EngineMode.TRANSFORM);
        } else if (args[i].equals(COMPILE)) {
            cliContext.setMap(args[++i]);
            cliContext.setMode(EngineMode.COMPILE);
        } else if (args[i].equals(NARRATIVE)) {
            cliContext.setMode(EngineMode.NARRATIVE);
        } else if (args[i].equals(SPREADSHEET)) {
            cliContext.setMode(EngineMode.SPREADSHEET);
        } else if (args[i].equals(SNAPSHOT)) {
            cliContext.setMode(EngineMode.SNAPSHOT);
        } else if (args[i].equals(SECURITY_CHECKS)) {
            cliContext.setSecurityChecks(true);
        } else if (args[i].equals(CRUMB_TRAIL)) {
            cliContext.setCrumbTrails(true);
        } else if (args[i].equals(VERBOSE)) {
            cliContext.setCrumbTrails(true);
        } else if (args[i].equals(ALLOW_EXAMPLE_URLS)) {
            String bl = args[++i];
            if ("true".equals(bl)) {
                cliContext.setAllowExampleUrls(true);
            } else if ("false".equals(bl)) {
                cliContext.setAllowExampleUrls(false);
            } else {
                throw new Error("Value for " + ALLOW_EXAMPLE_URLS + " not understood: " + bl);
            }
        } else if (args[i].equals(SHOW_TIMES)) {
            cliContext.setShowTimes(true);
        } else if (args[i].equals(OUTPUT_STYLE)) {
            cliContext.setOutputStyle(args[++i]);
        } else if (args[i].equals(SCAN)) {
            cliContext.setMode(EngineMode.SCAN);
        } else if (args[i].equals(TERMINOLOGY)) {
            if (i + 1 == args.length)
                throw new Error("Specified -tx without indicating terminology server");
            else
                cliContext.setTxServer("n/a".equals(args[++i]) ? null : args[i]);
        } else if (args[i].equals(TERMINOLOGY_LOG)) {
            if (i + 1 == args.length)
                throw new Error("Specified -txLog without indicating file");
            else
                cliContext.setTxLog(args[++i]);
        } else if (args[i].equals(TERMINOLOGY_CACHE)) {
            if (i + 1 == args.length)
                throw new Error("Specified -txCache without indicating file");
            else
                cliContext.setTxCache(args[++i]);
        } else if (args[i].equals(LOG)) {
            if (i + 1 == args.length)
                throw new Error("Specified -log without indicating file");
            else
                cliContext.setMapLog(args[++i]);
        } else if (args[i].equals(LANGUAGE)) {
            if (i + 1 == args.length)
                throw new Error("Specified -language without indicating language");
            else
                cliContext.setLang(args[++i]);
        } else if (args[i].equals(IMPLEMENTATION_GUIDE) || args[i].equals(DEFINITION)) {
            if (i + 1 == args.length)
                throw new Error("Specified " + args[i] + " without indicating ig file");
            else {
                String s = args[++i];
                String version = Common.getVersionFromIGName(null, s);
                if (version == null) {
                    cliContext.addIg(s);
                } else {
                    cliContext.setSv(version);
                }
            }
        } else if (args[i].equals(MAP)) {
            if (cliContext.getMap() == null) {
                if (i + 1 == args.length)
                    throw new Error("Specified -map without indicating map file");
                else
                    cliContext.setMap(args[++i]);
            } else {
                throw new Exception("Can only nominate a single -map parameter");
            }
        } else if (args[i].startsWith(X)) {
            i++;
        } else if (args[i].equals(CONVERT)) {
            cliContext.setMode(EngineMode.CONVERT);
        } else if (args[i].equals(FHIRPATH)) {
            cliContext.setMode(EngineMode.FHIRPATH);
            if (cliContext.getFhirpath() == null)
                if (i + 1 == args.length)
                    throw new Error("Specified -fhirpath without indicating a FHIRPath expression");
                else
                    cliContext.setFhirpath(args[++i]);
            else
                throw new Exception("Can only nominate a single -fhirpath parameter");
        } else {
            cliContext.addSource(args[i]);
        }
    }
    return cliContext;
}
Also used : Locale(java.util.Locale) BundleValidationRule(org.hl7.fhir.r5.utils.validation.BundleValidationRule) CliContext(org.hl7.fhir.validation.cli.model.CliContext)

Example 97 with Expression

use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeOperationOutcomeOperationOutcomeIssueComponent.

protected void composeOperationOutcomeOperationOutcomeIssueComponent(Complex parent, String parentType, String name, OperationOutcome.OperationOutcomeIssueComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "issue", name, element, index);
    if (element.hasSeverityElement())
        composeEnum(t, "OperationOutcome", "severity", element.getSeverityElement(), -1);
    if (element.hasCodeElement())
        composeEnum(t, "OperationOutcome", "code", element.getCodeElement(), -1);
    if (element.hasDetails())
        composeCodeableConcept(t, "OperationOutcome", "details", element.getDetails(), -1);
    if (element.hasDiagnosticsElement())
        composeString(t, "OperationOutcome", "diagnostics", element.getDiagnosticsElement(), -1);
    for (int i = 0; i < element.getLocation().size(); i++) composeString(t, "OperationOutcome", "location", element.getLocation().get(i), i);
    for (int i = 0; i < element.getExpression().size(); i++) composeString(t, "OperationOutcome", "expression", element.getExpression().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 98 with Expression

use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeGraphDefinitionGraphDefinitionLinkTargetCompartmentComponent.

protected void composeGraphDefinitionGraphDefinitionLinkTargetCompartmentComponent(Complex parent, String parentType, String name, GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "compartment", name, element, index);
    if (element.hasUseElement())
        composeEnum(t, "GraphDefinition", "use", element.getUseElement(), -1);
    if (element.hasCodeElement())
        composeEnum(t, "GraphDefinition", "code", element.getCodeElement(), -1);
    if (element.hasRuleElement())
        composeEnum(t, "GraphDefinition", "rule", element.getRuleElement(), -1);
    if (element.hasExpressionElement())
        composeString(t, "GraphDefinition", "expression", element.getExpressionElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "GraphDefinition", "description", element.getDescriptionElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 99 with Expression

use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeTestScriptSetupActionAssertComponent.

protected void composeTestScriptSetupActionAssertComponent(Complex parent, String parentType, String name, TestScript.SetupActionAssertComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "assert", name, element, index);
    if (element.hasLabelElement())
        composeString(t, "TestScript", "label", element.getLabelElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "TestScript", "description", element.getDescriptionElement(), -1);
    if (element.hasDirectionElement())
        composeEnum(t, "TestScript", "direction", element.getDirectionElement(), -1);
    if (element.hasCompareToSourceIdElement())
        composeString(t, "TestScript", "compareToSourceId", element.getCompareToSourceIdElement(), -1);
    if (element.hasCompareToSourceExpressionElement())
        composeString(t, "TestScript", "compareToSourceExpression", element.getCompareToSourceExpressionElement(), -1);
    if (element.hasCompareToSourcePathElement())
        composeString(t, "TestScript", "compareToSourcePath", element.getCompareToSourcePathElement(), -1);
    if (element.hasContentTypeElement())
        composeCode(t, "TestScript", "contentType", element.getContentTypeElement(), -1);
    if (element.hasExpressionElement())
        composeString(t, "TestScript", "expression", element.getExpressionElement(), -1);
    if (element.hasHeaderFieldElement())
        composeString(t, "TestScript", "headerField", element.getHeaderFieldElement(), -1);
    if (element.hasMinimumIdElement())
        composeString(t, "TestScript", "minimumId", element.getMinimumIdElement(), -1);
    if (element.hasNavigationLinksElement())
        composeBoolean(t, "TestScript", "navigationLinks", element.getNavigationLinksElement(), -1);
    if (element.hasOperatorElement())
        composeEnum(t, "TestScript", "operator", element.getOperatorElement(), -1);
    if (element.hasPathElement())
        composeString(t, "TestScript", "path", element.getPathElement(), -1);
    if (element.hasRequestMethodElement())
        composeEnum(t, "TestScript", "requestMethod", element.getRequestMethodElement(), -1);
    if (element.hasRequestURLElement())
        composeString(t, "TestScript", "requestURL", element.getRequestURLElement(), -1);
    if (element.hasResourceElement())
        composeCode(t, "TestScript", "resource", element.getResourceElement(), -1);
    if (element.hasResponseElement())
        composeEnum(t, "TestScript", "response", element.getResponseElement(), -1);
    if (element.hasResponseCodeElement())
        composeString(t, "TestScript", "responseCode", element.getResponseCodeElement(), -1);
    if (element.hasSourceIdElement())
        composeId(t, "TestScript", "sourceId", element.getSourceIdElement(), -1);
    if (element.hasValidateProfileIdElement())
        composeId(t, "TestScript", "validateProfileId", element.getValidateProfileIdElement(), -1);
    if (element.hasValueElement())
        composeString(t, "TestScript", "value", element.getValueElement(), -1);
    if (element.hasWarningOnlyElement())
        composeBoolean(t, "TestScript", "warningOnly", element.getWarningOnlyElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 100 with Expression

use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeRequestGroupRequestGroupActionConditionComponent.

protected void composeRequestGroupRequestGroupActionConditionComponent(Complex parent, String parentType, String name, RequestGroup.RequestGroupActionConditionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "condition", name, element, index);
    if (element.hasKindElement())
        composeEnum(t, "RequestGroup", "kind", element.getKindElement(), -1);
    if (element.hasExpression())
        composeExpression(t, "RequestGroup", "expression", element.getExpression(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

Test (org.junit.Test)102 Expression (org.apache.commons.jexl2.Expression)98 TermWeightPosition (datawave.ingest.protobuf.TermWeightPosition)66 Zone (datawave.query.jexl.functions.TermFrequencyList.Zone)66 Test (org.junit.jupiter.api.Test)60 ArrayList (java.util.ArrayList)36 HashMap (java.util.HashMap)35 Patient (org.hl7.fhir.r4.model.Patient)29 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)28 CqlVersionedIdentifier (com.ibm.cohort.cql.library.CqlVersionedIdentifier)28 Expression (io.atlasmap.v2.Expression)26 JexlContext (org.apache.commons.jexl2.JexlContext)26 Expression (org.hl7.elm.r1.Expression)26 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 CqlEvaluationResult (com.ibm.cohort.cql.evaluation.CqlEvaluationResult)24 JexlEngine (org.apache.commons.jexl2.JexlEngine)22 MapContext (org.apache.commons.jexl2.MapContext)22 FHIRException (org.hl7.fhir.exceptions.FHIRException)19 FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)16 Coding (org.hl7.fhir.r4.model.Coding)15