Search in sources :

Example 1 with StructureMapTargetListMode

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

the class StructureMapUtilities method renderTarget.

private static void renderTarget(StringBuilder b, StructureMapGroupRuleTargetComponent rt, boolean abbreviate) {
    if (rt.hasContext()) {
        if (rt.getContextType() == StructureMapContextType.TYPE)
            b.append("@");
        b.append(rt.getContext());
        if (rt.hasElement()) {
            b.append('.');
            b.append(rt.getElement());
        }
    }
    if (!abbreviate && rt.hasTransform()) {
        if (rt.hasContext())
            b.append(" = ");
        if (rt.getTransform() == StructureMapTransform.COPY && rt.getParameter().size() == 1) {
            renderTransformParam(b, rt.getParameter().get(0));
        } else if (rt.getTransform() == StructureMapTransform.EVALUATE && rt.getParameter().size() == 1) {
            b.append("(");
            b.append("\"" + ((StringType) rt.getParameter().get(0).getValue()).asStringValue() + "\"");
            b.append(")");
        } else if (rt.getTransform() == StructureMapTransform.EVALUATE && rt.getParameter().size() == 2) {
            b.append(rt.getTransform().toCode());
            b.append("(");
            b.append(((IdType) rt.getParameter().get(0).getValue()).asStringValue());
            b.append("\"" + ((StringType) rt.getParameter().get(1).getValue()).asStringValue() + "\"");
            b.append(")");
        } else {
            b.append(rt.getTransform().toCode());
            b.append("(");
            boolean first = true;
            for (StructureMapGroupRuleTargetParameterComponent rtp : rt.getParameter()) {
                if (first)
                    first = false;
                else
                    b.append(", ");
                renderTransformParam(b, rtp);
            }
            b.append(")");
        }
    }
    if (!abbreviate && rt.hasVariable()) {
        b.append(" as ");
        b.append(rt.getVariable());
    }
    for (Enumeration<StructureMapTargetListMode> lm : rt.getListMode()) {
        b.append(" ");
        b.append(lm.getValue().toCode());
        if (lm.getValue() == StructureMapTargetListMode.SHARE) {
            b.append(" ");
            b.append(rt.getListRuleId());
        }
    }
}
Also used : StructureMapTargetListMode(org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode) StringType(org.hl7.fhir.dstu3.model.StringType) StructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent)

Example 2 with StructureMapTargetListMode

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

the class StructureMapUtilities method renderTarget.

private static void renderTarget(StringBuilder b, StructureMapGroupRuleTargetComponent rt, boolean abbreviate) {
    if (rt.hasContext()) {
        if (rt.getContextType() == StructureMapContextType.TYPE)
            b.append("@");
        b.append(rt.getContext());
        if (rt.hasElement()) {
            b.append('.');
            b.append(rt.getElement());
        }
    }
    if (!abbreviate && rt.hasTransform()) {
        if (rt.hasContext())
            b.append(" = ");
        if (rt.getTransform() == StructureMapTransform.COPY && rt.getParameter().size() == 1) {
            renderTransformParam(b, rt.getParameter().get(0));
        } else if (rt.getTransform() == StructureMapTransform.EVALUATE && rt.getParameter().size() == 1) {
            b.append("(");
            b.append("\"" + ((StringType) rt.getParameter().get(0).getValue()).asStringValue() + "\"");
            b.append(")");
        } else if (rt.getTransform() == StructureMapTransform.EVALUATE && rt.getParameter().size() == 2) {
            b.append(rt.getTransform().toCode());
            b.append("(");
            b.append(((IdType) rt.getParameter().get(0).getValue()).asStringValue());
            b.append("\"" + ((StringType) rt.getParameter().get(1).getValue()).asStringValue() + "\"");
            b.append(")");
        } else {
            b.append(rt.getTransform().toCode());
            b.append("(");
            boolean first = true;
            for (StructureMapGroupRuleTargetParameterComponent rtp : rt.getParameter()) {
                if (first)
                    first = false;
                else
                    b.append(", ");
                renderTransformParam(b, rtp);
            }
            b.append(")");
        }
    }
    if (!abbreviate && rt.hasVariable()) {
        b.append(" as ");
        b.append(rt.getVariable());
    }
    for (Enumeration<StructureMapTargetListMode> lm : rt.getListMode()) {
        b.append(" ");
        b.append(lm.getValue().toCode());
        if (lm.getValue() == StructureMapTargetListMode.SHARE) {
            b.append(" ");
            b.append(rt.getListRuleId());
        }
    }
}
Also used : StructureMapTargetListMode(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode) StringType(org.hl7.fhir.r4.model.StringType) StructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent)

Aggregations

StringType (org.hl7.fhir.dstu3.model.StringType)1 StructureMapGroupRuleTargetParameterComponent (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleTargetParameterComponent)1 StructureMapTargetListMode (org.hl7.fhir.dstu3.model.StructureMap.StructureMapTargetListMode)1 StringType (org.hl7.fhir.r4.model.StringType)1 StructureMapGroupRuleTargetParameterComponent (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent)1 StructureMapTargetListMode (org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode)1