use of org.hl7.fhir.r4b.model.StructureMap in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeStructureMapStructureMapGroupRuleDependentComponent.
protected void composeStructureMapStructureMapGroupRuleDependentComponent(Complex parent, String parentType, String name, StructureMap.StructureMapGroupRuleDependentComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "dependent", name, element, index);
if (element.hasNameElement())
composeId(t, "StructureMap", "name", element.getNameElement(), -1);
for (int i = 0; i < element.getVariable().size(); i++) composeString(t, "StructureMap", "variable", element.getVariable().get(i), i);
}
use of org.hl7.fhir.r4b.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);
}
use of org.hl7.fhir.r4b.model.StructureMap in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeStructureMapStructureMapGroupInputComponent.
protected void composeStructureMapStructureMapGroupInputComponent(Complex parent, String parentType, String name, StructureMap.StructureMapGroupInputComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "input", name, element, index);
if (element.hasNameElement())
composeId(t, "StructureMap", "name", element.getNameElement(), -1);
if (element.hasTypeElement())
composeString(t, "StructureMap", "type", element.getTypeElement(), -1);
if (element.hasModeElement())
composeEnum(t, "StructureMap", "mode", element.getModeElement(), -1);
if (element.hasDocumentationElement())
composeString(t, "StructureMap", "documentation", element.getDocumentationElement(), -1);
}
use of org.hl7.fhir.r4b.model.StructureMap in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeStructureMapStructureMapGroupRuleTargetParameterComponent.
protected void composeStructureMapStructureMapGroupRuleTargetParameterComponent(Complex parent, String parentType, String name, StructureMap.StructureMapGroupRuleTargetParameterComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "parameter", name, element, index);
if (element.hasValue())
composeType(t, "StructureMap", "value", element.getValue(), -1);
}
use of org.hl7.fhir.r4b.model.StructureMap in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method runTransform.
private Base runTransform(TransformContext context, StructureMap map, StructureMapGroupRuleTargetComponent tgt, Variables vars) throws FHIRException {
switch(tgt.getTransform()) {
case CREATE:
return ResourceFactory.createResourceOrType(getParamString(vars, tgt.getParameter().get(0)));
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(1)));
tgt.setUserData(MAP_WHERE_EXPRESSION, expr);
}
List<Base> v = fpe.evaluate(null, null, getParam(vars, tgt.getParameter().get(0)), expr);
if (v.size() != 1)
throw new FHIRException("evaluation of " + expr.toString() + " returned " + Integer.toString(v.size()) + " objects");
return v.get(0);
case TRUNCATE:
String src = getParamString(vars, tgt.getParameter().get(0));
String len = getParamString(vars, tgt.getParameter().get(1));
if (Utilities.isInteger(len)) {
int l = Integer.parseInt(len);
if (src.length() > l)
src = src.substring(0, l);
}
return new StringType(src);
case ESCAPE:
throw new Error("Transform " + tgt.getTransform().toCode() + " not supported yet");
case CAST:
throw new Error("Transform " + tgt.getTransform().toCode() + " not supported yet");
case APPEND:
throw new Error("Transform " + tgt.getTransform().toCode() + " not supported yet");
case TRANSLATE:
return translate(context, map, vars, tgt.getParameter());
case REFERENCE:
throw new Error("Transform " + tgt.getTransform().toCode() + " not supported yet");
case DATEOP:
throw new Error("Transform " + tgt.getTransform().toCode() + " not supported yet");
case UUID:
return new IdType(UUID.randomUUID().toString());
case POINTER:
Base b = getParam(vars, tgt.getParameter().get(0));
if (b instanceof Resource)
return new UriType("urn:uuid:" + ((Resource) b).getId());
else
throw new FHIRException("Transform engine cannot point at an element of type " + b.fhirType());
default:
throw new Error("Transform Unknown: " + tgt.getTransform().toCode());
}
}
Aggregations