public String castToXhtmlString(Base b) throws FHIRException { if (b instanceof Element) { return ((Element) b).getValue(); } else if (b instanceof XhtmlType) { try { return new XhtmlComposer(true).compose(((XhtmlType) b).getValue()); } catch (IOException e) { return null; } } else if (b instanceof StringType) { return ((StringType) b).asStringValue(); } else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml string"); }
public XhtmlNode castToXhtml(Base b) throws FHIRException { if (b instanceof Element) { return ((Element) b).getXhtml(); } else if (b instanceof XhtmlType) { return ((XhtmlType) b).getValue(); } else if (b instanceof StringType) { try { return new XhtmlParser().parseFragment(((StringType) b).asStringValue()); } catch (IOException e) { throw new FHIRException(e); } } else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml"); }
b.append(" default "); assert rs.getDefaultValue() instanceof StringType; b.append("\""+Utilities.escapeJson(((StringType) rs.getDefaultValue()).asStringValue())+"\"");
} 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("("); b.append(((IdType) rt.getParameter().get(0).getValue()).asStringValue()); b.append("\""+((StringType) rt.getParameter().get(1).getValue()).asStringValue()+"\""); b.append(")"); } else {
private static void renderTransformParam(StringBuilder b, StructureMapGroupRuleTargetParameterComponent rtp) { try { if (rtp.hasValueBooleanType()) b.append(rtp.getValueBooleanType().asStringValue()); else if (rtp.hasValueDecimalType()) b.append(rtp.getValueDecimalType().asStringValue()); else if (rtp.hasValueIdType()) b.append(rtp.getValueIdType().asStringValue()); else if (rtp.hasValueDecimalType()) b.append(rtp.getValueDecimalType().asStringValue()); else if (rtp.hasValueIntegerType()) b.append(rtp.getValueIntegerType().asStringValue()); else b.append("'"+Utilities.escapeJava(rtp.getValueStringType().asStringValue())+"'"); } catch (FHIRException e) { e.printStackTrace(); b.append("error!"); } }
else b.append(", "); b.append(rdp.asStringValue());
private void executeDependency(String indent, TransformContext context, StructureMap map, Variables vin, StructureMapGroupComponent group, StructureMapGroupRuleDependentComponent dependent) throws FHIRException { ResolvedGroup rg = resolveGroupReference(map, group, dependent.getName()); if (rg.target.getInput().size() != dependent.getVariable().size()) { throw new FHIRException("Rule '"+dependent.getName()+"' has "+Integer.toString(rg.target.getInput().size())+" but the invocation has "+Integer.toString(dependent.getVariable().size())+" variables"); } Variables v = new Variables(); for (int i = 0; i < rg.target.getInput().size(); i++) { StructureMapGroupInputComponent input = rg.target.getInput().get(i); StringType rdp = dependent.getVariable().get(i); String var = rdp.asStringValue(); VariableMode mode = input.getMode() == StructureMapInputMode.SOURCE ? VariableMode.INPUT : VariableMode.OUTPUT; Base vv = vin.get(mode, var); if (vv == null && mode == VariableMode.INPUT) //* once source, always source. but target can be treated as source at user convenient vv = vin.get(VariableMode.OUTPUT, var); if (vv == null) throw new FHIRException("Rule '"+dependent.getName()+"' "+mode.toString()+" variable '"+input.getName()+"' named as '"+var+"' has no value (vars = "+vin.summary()+")"); v.add(mode, input.getName(), vv); } executeGroup(indent+" ", context, rg.targetMap, v, rg.target, false); }
public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent(); copyElement(src, tgt); tgt.setName(src.getName()); for (org.hl7.fhir.r4.model.StringType t : src.getVariable()) tgt.addVariable(t.asStringValue()); return tgt; }
this.value = castToString(value).asStringValue(); return this;
} else if (value instanceof StringType) { Coding cc = new Coding(); cc.setCode(((StringType) value).asStringValue()); cc.setSystem(getSystemForCode(vs, cc.getCode(), path)); return cc; else if (value instanceof StringType) { Reference r = new Reference(); r.setReference(((StringType) value).asStringValue());
public String castToXhtmlString(Base b) throws FHIRException { if (b instanceof Element) { return ((Element) b).getValue(); } else if (b instanceof XhtmlType) { try { return new XhtmlComposer(true).compose(((XhtmlType) b).getValue()); } catch (IOException e) { return null; } } else if (b instanceof StringType) { return ((StringType) b).asStringValue(); } else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml string"); }
public XhtmlNode castToXhtml(Base b) throws FHIRException { if (b instanceof Element) { return ((Element) b).getXhtml(); } else if (b instanceof XhtmlType) { return ((XhtmlType) b).getValue(); } else if (b instanceof StringType) { try { return new XhtmlParser().parseFragment(((StringType) b).asStringValue()); } catch (IOException e) { throw new FHIRException(e); } } else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml"); }
b.append(" default "); assert rs.getDefaultValue() instanceof StringType; b.append("\""+Utilities.escapeJson(((StringType) rs.getDefaultValue()).asStringValue())+"\"");
} 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("("); b.append(((IdType) rt.getParameter().get(0).getValue()).asStringValue()); b.append("\""+((StringType) rt.getParameter().get(1).getValue()).asStringValue()+"\""); b.append(")"); } else {
else b.append(", "); b.append(rdp.asStringValue());
private static void renderTransformParam(StringBuilder b, StructureMapGroupRuleTargetParameterComponent rtp) { try { if (rtp.hasValueBooleanType()) b.append(rtp.getValueBooleanType().asStringValue()); else if (rtp.hasValueDecimalType()) b.append(rtp.getValueDecimalType().asStringValue()); else if (rtp.hasValueIdType()) b.append(rtp.getValueIdType().asStringValue()); else if (rtp.hasValueDecimalType()) b.append(rtp.getValueDecimalType().asStringValue()); else if (rtp.hasValueIntegerType()) b.append(rtp.getValueIntegerType().asStringValue()); else b.append("'"+Utilities.escapeJava(rtp.getValueStringType().asStringValue())+"'"); } catch (FHIRException e) { e.printStackTrace(); b.append("error!"); } }
private void executeDependency(String indent, TransformContext context, StructureMap map, Variables vin, StructureMapGroupComponent group, StructureMapGroupRuleDependentComponent dependent) throws FHIRException { ResolvedGroup rg = resolveGroupReference(map, group, dependent.getName()); if (rg.target.getInput().size() != dependent.getVariable().size()) { throw new FHIRException("Rule '"+dependent.getName()+"' has "+Integer.toString(rg.target.getInput().size())+" but the invocation has "+Integer.toString(dependent.getVariable().size())+" variables"); } Variables v = new Variables(); for (int i = 0; i < rg.target.getInput().size(); i++) { StructureMapGroupInputComponent input = rg.target.getInput().get(i); StringType rdp = dependent.getVariable().get(i); String var = rdp.asStringValue(); VariableMode mode = input.getMode() == StructureMapInputMode.SOURCE ? VariableMode.INPUT : VariableMode.OUTPUT; Base vv = vin.get(mode, var); if (vv == null && mode == VariableMode.INPUT) //* once source, always source. but target can be treated as source at user convenient vv = vin.get(VariableMode.OUTPUT, var); if (vv == null) throw new FHIRException("Rule '"+dependent.getName()+"' "+mode.toString()+" variable '"+input.getName()+"' named as '"+var+"' has no value (vars = "+vin.summary()+")"); v.add(mode, input.getName(), vv); } executeGroup(indent+" ", context, rg.targetMap, v, rg.target, false); }
public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent(); copyElement(src, tgt); tgt.setName(src.getName()); for (org.hl7.fhir.r4.model.StringType t : src.getVariable()) tgt.addVariable(t.asStringValue()); return tgt; }
this.value = castToString(value).asStringValue(); return this;
} else if (value instanceof StringType) { Coding cc = new Coding(); cc.setCode(((StringType) value).asStringValue()); cc.setSystem(getSystemForCode(vs, cc.getCode(), path)); return cc; else if (value instanceof StringType) { Reference r = new Reference(); r.setReference(((StringType) value).asStringValue());