Search in sources :

Example 96 with StructureMap

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

the class StructureMapUtilities method analyseGroup.

private void analyseGroup(String indent, TransformContext context, StructureMap map, VariablesForProfiling vars, StructureMapGroupComponent group, StructureMapAnalysis result) throws FHIRException {
    log(indent + "Analyse Group : " + group.getName());
    // todo: extends
    // todo: check inputs
    XhtmlNode tr = result.summary.addTag("tr").setAttribute("class", "diff-title");
    XhtmlNode xs = tr.addTag("td");
    XhtmlNode xt = tr.addTag("td");
    for (StructureMapGroupInputComponent inp : group.getInput()) {
        if (inp.getMode() == StructureMapInputMode.SOURCE)
            noteInput(vars, inp, VariableMode.INPUT, xs);
        if (inp.getMode() == StructureMapInputMode.TARGET)
            noteInput(vars, inp, VariableMode.OUTPUT, xt);
    }
    for (StructureMapGroupRuleComponent r : group.getRule()) {
        analyseRule(indent + "  ", context, map, vars, group, r, result);
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 97 with StructureMap

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

the class StructureMapUtilities method analyseTransform.

private TypeDetails analyseTransform(TransformContext context, StructureMap map, StructureMapGroupRuleTargetComponent tgt, VariableForProfiling var, VariablesForProfiling vars) throws FHIRException {
    switch(tgt.getTransform()) {
        case CREATE:
            String p = getParamString(vars, tgt.getParameter().get(0));
            return new TypeDetails(CollectionStatus.SINGLETON, p);
        case COPY:
            return getParam(vars, tgt.getParameter().get(0));
        case EVALUATE:
            ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION);
            if (expr == null) {
                expr = fpe.parse(getParamString(vars, tgt.getParameter().get(tgt.getParameter().size() - 1)));
                tgt.setUserData(MAP_WHERE_EXPRESSION, expr);
            }
            return fpe.check(vars, null, expr);
        case TRANSLATE:
            return new TypeDetails(CollectionStatus.SINGLETON, "CodeableConcept");
        case CC:
            ProfiledType res = new ProfiledType("CodeableConcept");
            if (tgt.getParameter().size() >= 2 && isParamId(vars, tgt.getParameter().get(1))) {
                TypeDetails td = vars.get(null, getParamId(vars, tgt.getParameter().get(1))).getProperty().getTypes();
                if (td != null && td.hasBinding())
                    // todo: do we need to check that there's no implicit translation her? I don't think we do...
                    res.addBinding(td.getBinding());
            }
            return new TypeDetails(CollectionStatus.SINGLETON, res);
        case C:
            return new TypeDetails(CollectionStatus.SINGLETON, "Coding");
        case QTY:
            return new TypeDetails(CollectionStatus.SINGLETON, "Quantity");
        case REFERENCE:
            VariableForProfiling vrs = vars.get(VariableMode.OUTPUT, getParamId(vars, tgt.getParameterFirstRep()));
            if (vrs == null)
                throw new FHIRException("Unable to resolve variable \"" + getParamId(vars, tgt.getParameterFirstRep()) + "\"");
            String profile = vrs.getProperty().getProfileProperty().getStructure().getUrl();
            TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON);
            td.addType("Reference", profile);
            return td;
        default:
            throw new Error("Transform Unknown or not handled yet: " + tgt.getTransform().toCode());
    }
}
Also used : ProfiledType(org.hl7.fhir.r5.model.TypeDetails.ProfiledType) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 98 with StructureMap

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

the class RdfParser method composeStructureMapStructureMapContactComponent.

protected void composeStructureMapStructureMapContactComponent(Complex parent, String parentType, String name, StructureMap.StructureMapContactComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "contact", name, element, index);
    if (element.hasNameElement())
        composeString(t, "StructureMap", "name", element.getNameElement(), -1);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "StructureMap", "telecom", element.getTelecom().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 99 with StructureMap

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

the class RdfParser method composeStructureMapStructureMapGroupRuleComponent.

protected void composeStructureMapStructureMapGroupRuleComponent(Complex parent, String parentType, String name, StructureMap.StructureMapGroupRuleComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "rule", name, element, index);
    if (element.hasNameElement())
        composeId(t, "StructureMap", "name", element.getNameElement(), -1);
    for (int i = 0; i < element.getSource().size(); i++) composeStructureMapStructureMapGroupRuleSourceComponent(t, "StructureMap", "source", element.getSource().get(i), i);
    for (int i = 0; i < element.getTarget().size(); i++) composeStructureMapStructureMapGroupRuleTargetComponent(t, "StructureMap", "target", element.getTarget().get(i), i);
    for (int i = 0; i < element.getRule().size(); i++) composeStructureMapStructureMapGroupRuleComponent(t, "StructureMap", "rule", element.getRule().get(i), i);
    for (int i = 0; i < element.getDependent().size(); i++) composeStructureMapStructureMapGroupRuleDependentComponent(t, "StructureMap", "dependent", element.getDependent().get(i), i);
    if (element.hasDocumentationElement())
        composeString(t, "StructureMap", "documentation", element.getDocumentationElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 100 with StructureMap

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

the class RdfParser method composeStructureMapStructureMapGroupRuleTargetComponent.

protected void composeStructureMapStructureMapGroupRuleTargetComponent(Complex parent, String parentType, String name, StructureMap.StructureMapGroupRuleTargetComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "target", name, element, index);
    if (element.hasContextElement())
        composeId(t, "StructureMap", "context", element.getContextElement(), -1);
    if (element.hasContextTypeElement())
        composeEnum(t, "StructureMap", "contextType", element.getContextTypeElement(), -1);
    if (element.hasElementElement())
        composeString(t, "StructureMap", "element", element.getElementElement(), -1);
    if (element.hasVariableElement())
        composeId(t, "StructureMap", "variable", element.getVariableElement(), -1);
    for (int i = 0; i < element.getListMode().size(); i++) composeEnum(t, "StructureMap", "listMode", element.getListMode().get(i), i);
    if (element.hasListRuleIdElement())
        composeId(t, "StructureMap", "listRuleId", element.getListRuleIdElement(), -1);
    if (element.hasTransformElement())
        composeEnum(t, "StructureMap", "transform", element.getTransformElement(), -1);
    for (int i = 0; i < element.getParameter().size(); i++) composeStructureMapStructureMapGroupRuleTargetParameterComponent(t, "StructureMap", "parameter", element.getParameter().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)69 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)23 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)17 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 StructureMap (org.hl7.fhir.r4b.model.StructureMap)13 StructureMap (org.hl7.fhir.r5.model.StructureMap)13 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 StructureMap (org.hl7.fhir.r4.model.StructureMap)11 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)10 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)9 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)9 StructureMap (org.hl7.fhir.dstu3.model.StructureMap)8 File (java.io.File)7 UriType (org.hl7.fhir.r4.model.UriType)7 Test (org.junit.jupiter.api.Test)7 Base (org.hl7.fhir.dstu3.model.Base)6 TextFile (org.hl7.fhir.utilities.TextFile)6 FileOutputStream (java.io.FileOutputStream)5