Search in sources :

Example 61 with Expression

use of org.hl7.fhir.r5.model.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 62 with Expression

use of org.hl7.fhir.r5.model.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 63 with Expression

use of org.hl7.fhir.r5.model.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)

Example 64 with Expression

use of org.hl7.fhir.r5.model.Expression in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeElementDefinitionElementDefinitionConstraintComponent.

protected void composeElementDefinitionElementDefinitionConstraintComponent(Complex parent, String parentType, String name, ElementDefinition.ElementDefinitionConstraintComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "constraint", name, element, index);
    if (element.hasKeyElement())
        composeId(t, "ElementDefinition", "key", element.getKeyElement(), -1);
    if (element.hasRequirementsElement())
        composeString(t, "ElementDefinition", "requirements", element.getRequirementsElement(), -1);
    if (element.hasSeverityElement())
        composeEnum(t, "ElementDefinition", "severity", element.getSeverityElement(), -1);
    if (element.hasHumanElement())
        composeString(t, "ElementDefinition", "human", element.getHumanElement(), -1);
    if (element.hasExpressionElement())
        composeString(t, "ElementDefinition", "expression", element.getExpressionElement(), -1);
    if (element.hasXpathElement())
        composeString(t, "ElementDefinition", "xpath", element.getXpathElement(), -1);
    if (element.hasSourceElement())
        composeCanonical(t, "ElementDefinition", "source", element.getSourceElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 65 with Expression

use of org.hl7.fhir.r5.model.Expression in project org.hl7.fhir.core by hapifhir.

the class ProfileDrivenRenderer method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode parent, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        return;
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType) {
        renderDateTime(x, e);
    } else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.r4b.model.DateType) {
        org.hl7.fhir.r4b.model.DateType dt = ((org.hl7.fhir.r4b.model.DateType) e);
        if (((org.hl7.fhir.r4b.model.DateType) e).hasValue()) {
            x.addText(((org.hl7.fhir.r4b.model.DateType) e).toHumanDisplay());
        }
    } else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType) {
        x.addText(((BooleanType) e).getValue().toString());
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept(x, (CodeableConcept) e, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding(x, (Coding) e, showCodeDetails);
    } else if (e instanceof CodeableReference) {
        renderCodeableReference(x, (CodeableReference) e, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation(x, (Annotation) e);
    } else if (e instanceof Identifier) {
        renderIdentifier(x, (Identifier) e);
    } else if (e instanceof org.hl7.fhir.r4b.model.IntegerType) {
        if (((org.hl7.fhir.r4b.model.IntegerType) e).hasValue()) {
            x.addText(Integer.toString(((org.hl7.fhir.r4b.model.IntegerType) e).getValue()));
        } else {
            x.addText("??");
        }
    } else if (e instanceof org.hl7.fhir.r4b.model.Integer64Type) {
        if (((org.hl7.fhir.r4b.model.Integer64Type) e).hasValue()) {
            x.addText(Long.toString(((org.hl7.fhir.r4b.model.Integer64Type) e).getValue()));
        } else {
            x.addText("??");
        }
    } else if (e instanceof org.hl7.fhir.r4b.model.DecimalType) {
        x.addText(((org.hl7.fhir.r4b.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName(x, (HumanName) e);
    } else if (e instanceof SampledData) {
        renderSampledData(x, (SampledData) e);
    } else if (e instanceof Address) {
        renderAddress(x, (Address) e);
    } else if (e instanceof ContactPoint) {
        renderContactPoint(x, (ContactPoint) e);
    } else if (e instanceof Expression) {
        renderExpression(x, (Expression) e);
    } else if (e instanceof Money) {
        renderMoney(x, (Money) e);
    } else if (e instanceof ContactDetail) {
        ContactDetail cd = (ContactDetail) e;
        if (cd.hasName()) {
            x.tx(cd.getName() + ": ");
        }
        boolean first = true;
        for (ContactPoint c : cd.getTelecom()) {
            if (first)
                first = false;
            else
                x.tx(",");
            renderContactPoint(x, c);
        }
    } else if (e instanceof UriType) {
        renderUri(x, (UriType) e, defn.getPath(), rcontext != null && rcontext.getResourceResource() != null ? rcontext.getResourceResource().getId() : null);
    } else if (e instanceof Timing) {
        renderTiming(x, (Timing) e);
    } else if (e instanceof Range) {
        renderRange(x, (Range) e);
    } else if (e instanceof Quantity) {
        renderQuantity(x, (Quantity) e, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(x, ((Ratio) e).getNumerator(), showCodeDetails);
        x.tx("/");
        renderQuantity(x, ((Ratio) e).getDenominator(), showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        renderPeriod(x, p);
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        if (r.getReference() != null && r.getReference().contains("#")) {
            if (containedIds.contains(r.getReference().substring(1))) {
                x.ah(r.getReference()).tx("See " + r.getReference());
            } else {
                // in this case, we render the resource in line
                ResourceWrapper rw = null;
                for (ResourceWrapper t : res.getContained()) {
                    if (r.getReference().substring(1).equals(t.getId())) {
                        rw = t;
                    }
                }
                if (rw == null) {
                    renderReference(res, x, r);
                } else {
                    x.an(rw.getId());
                    ResourceRenderer rr = RendererFactory.factory(rw, context.copy().setAddGeneratedNarrativeHeader(false));
                    rr.render(parent.blockquote(), rw);
                }
            }
        } else {
            renderReference(res, x, r);
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof DataRequirement) {
        DataRequirement p = (DataRequirement) e;
        renderDataRequirement(x, p);
    } else if (e instanceof PrimitiveType) {
        x.tx(((PrimitiveType) e).primitiveValue());
    } else if (e instanceof ElementDefinition) {
        x.tx("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled - should not be here");
    }
}
Also used : ResourceWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper) Meta(org.hl7.fhir.r4b.model.Meta) Address(org.hl7.fhir.r4b.model.Address) StringType(org.hl7.fhir.r4b.model.StringType) Attachment(org.hl7.fhir.r4b.model.Attachment) DataRequirement(org.hl7.fhir.r4b.model.DataRequirement) Identifier(org.hl7.fhir.r4b.model.Identifier) Coding(org.hl7.fhir.r4b.model.Coding) Narrative(org.hl7.fhir.r4b.model.Narrative) SampledData(org.hl7.fhir.r4b.model.SampledData) PrimitiveType(org.hl7.fhir.r4b.model.PrimitiveType) ElementDefinition(org.hl7.fhir.r4b.model.ElementDefinition) InstantType(org.hl7.fhir.r4b.model.InstantType) DomainResource(org.hl7.fhir.r4b.model.DomainResource) Resource(org.hl7.fhir.r4b.model.Resource) Period(org.hl7.fhir.r4b.model.Period) Range(org.hl7.fhir.r4b.model.Range) IdType(org.hl7.fhir.r4b.model.IdType) DateTimeType(org.hl7.fhir.r4b.model.DateTimeType) Timing(org.hl7.fhir.r4b.model.Timing) CodeableConcept(org.hl7.fhir.r4b.model.CodeableConcept) Base64(org.apache.commons.codec.binary.Base64) NotImplementedException(org.apache.commons.lang3.NotImplementedException) UriType(org.hl7.fhir.r4b.model.UriType) HumanName(org.hl7.fhir.r4b.model.HumanName) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) Money(org.hl7.fhir.r4b.model.Money) Ratio(org.hl7.fhir.r4b.model.Ratio) Enumeration(org.hl7.fhir.r4b.model.Enumeration) CodeableReference(org.hl7.fhir.r4b.model.CodeableReference) ResourceWithReference(org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceWithReference) Reference(org.hl7.fhir.r4b.model.Reference) BooleanType(org.hl7.fhir.r4b.model.BooleanType) Quantity(org.hl7.fhir.r4b.model.Quantity) Base(org.hl7.fhir.r4b.model.Base) Annotation(org.hl7.fhir.r4b.model.Annotation) Extension(org.hl7.fhir.r4b.model.Extension) ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) Expression(org.hl7.fhir.r4b.model.Expression) CodeableReference(org.hl7.fhir.r4b.model.CodeableReference) CodeType(org.hl7.fhir.r4b.model.CodeType) Base64BinaryType(org.hl7.fhir.r4b.model.Base64BinaryType)

Aggregations

HashMap (java.util.HashMap)33 Test (org.junit.Test)30 Test (org.junit.jupiter.api.Test)30 Patient (org.hl7.fhir.r4.model.Patient)29 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)28 CqlVersionedIdentifier (com.ibm.cohort.cql.library.CqlVersionedIdentifier)28 ArrayList (java.util.ArrayList)27 Expression (org.hl7.elm.r1.Expression)26 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 CqlEvaluationResult (com.ibm.cohort.cql.evaluation.CqlEvaluationResult)24 FHIRException (org.hl7.fhir.exceptions.FHIRException)19 FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)16 Coding (org.hl7.fhir.r4.model.Coding)15 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)14 Row (org.apache.spark.sql.Row)12 List (java.util.List)11 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)11 FhirPath (au.csiro.pathling.fhirpath.FhirPath)10 Nonnull (javax.annotation.Nonnull)10 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)9