private void buildFixedExpression(ElementDefinition ed, StringBuilder expression, String discriminator, ElementDefinition criteriaElement) throws DefinitionException { Type fixed = criteriaElement.getFixed(); if (fixed instanceof CodeableConcept) { CodeableConcept cc = (CodeableConcept) fixed; buildCodeableConceptExpression(ed, expression, discriminator, cc); } else { expression.append(" and (" + discriminator + " = "); if (fixed instanceof StringType) { Gson gson = new Gson(); String json = gson.toJson((StringType)fixed); String escapedString = json.substring(json.indexOf(":")+2); escapedString = escapedString.substring(0, escapedString.indexOf(",\"myStringValue")-1); expression.append("'" + escapedString + "'"); } else if (fixed instanceof UriType) { expression.append("'" + ((UriType)fixed).asStringValue() + "'"); } else if (fixed instanceof IntegerType) { expression.append(((IntegerType)fixed).asStringValue()); } else if (fixed instanceof DecimalType) { expression.append(((IntegerType)fixed).asStringValue()); } else if (fixed instanceof BooleanType) { expression.append(((BooleanType)fixed).asStringValue()); } else throw new DefinitionException("Unsupported fixed value type for discriminator(" + discriminator + ") for slice " + ed.getId() + ": " + fixed.getClass().getName()); expression.append(")"); } }
private Slicer generateSlicer(ElementDefinition child, ElementDefinitionSlicingComponent slicing, StructureDefinition structure) { // given a child in a structure, it's sliced. figure out the slicing xpath if (child.getPath().endsWith(".extension")) { ElementDefinition ued = getUrlFor(structure, child); if ((ued == null || !ued.hasFixed()) && !(child.hasType() && (child.getType().get(0).hasProfile()))) return new Slicer(false); else { Slicer s = new Slicer(true); String url = (ued == null || !ued.hasFixed()) ? child.getType().get(0).getProfile().get(0).getValue() : ((UriType) ued.getFixed()).asStringValue(); s.name = " with URL = '"+url+"'"; s.criteria = "[@url = '"+url+"']"; return s; } } else return new Slicer(false); }
private String getIncSummary(ConceptSetComponent cc) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (UriType vs : cc.getValueSet()) b.append(vs.asStringValue()); String vsd = b.length() > 0 ? " where the codes are in the value sets ("+b.toString()+")" : ""; String system = cc.getSystem(); if (cc.hasConcept()) return Integer.toString(cc.getConcept().size())+" codes from "+system+vsd; if (cc.hasFilter()) { String s = ""; for (ConceptSetFilterComponent f : cc.getFilter()) { if (!Utilities.noString(s)) s = s + " & "; s = s + f.getProperty()+" "+f.getOp().toCode()+" "+f.getValue(); } return "from "+system+" where "+s+vsd; } return "All codes from "+system+vsd; }
return (Type) value; else if (value instanceof UriType) return new StringType(((UriType) value).asStringValue()); break; case TEXT: if (value instanceof StringType) return (Type) value; break;
private void buildFixedExpression(ElementDefinition ed, StringBuilder expression, String discriminator, ElementDefinition criteriaElement) throws DefinitionException { Type fixed = criteriaElement.getFixed(); if (fixed instanceof CodeableConcept) { CodeableConcept cc = (CodeableConcept) fixed; buildCodeableConceptExpression(ed, expression, discriminator, cc); } else { expression.append(" and (" + discriminator + " = "); if (fixed instanceof StringType) { Gson gson = new Gson(); String json = gson.toJson((StringType)fixed); String escapedString = json.substring(json.indexOf(":")+2); escapedString = escapedString.substring(0, escapedString.indexOf(",\"myStringValue")-1); expression.append("'" + escapedString + "'"); } else if (fixed instanceof UriType) { expression.append("'" + ((UriType)fixed).asStringValue() + "'"); } else if (fixed instanceof IntegerType) { expression.append(((IntegerType)fixed).asStringValue()); } else if (fixed instanceof DecimalType) { expression.append(((IntegerType)fixed).asStringValue()); } else if (fixed instanceof BooleanType) { expression.append(((BooleanType)fixed).asStringValue()); } else throw new DefinitionException("Unsupported fixed value type for discriminator(" + discriminator + ") for slice " + ed.getId() + ": " + fixed.getClass().getName()); expression.append(")"); } }
private Slicer generateSlicer(ElementDefinition child, ElementDefinitionSlicingComponent slicing, StructureDefinition structure) { // given a child in a structure, it's sliced. figure out the slicing xpath if (child.getPath().endsWith(".extension")) { ElementDefinition ued = getUrlFor(structure, child); if ((ued == null || !ued.hasFixed()) && !(child.hasType() && (child.getType().get(0).hasProfile()))) return new Slicer(false); else { Slicer s = new Slicer(true); String url = (ued == null || !ued.hasFixed()) ? child.getType().get(0).getProfile().get(0).getValue() : ((UriType) ued.getFixed()).asStringValue(); s.name = " with URL = '"+url+"'"; s.criteria = "[@url = '"+url+"']"; return s; } } else return new Slicer(false); }
private String getIncSummary(ConceptSetComponent cc) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (UriType vs : cc.getValueSet()) b.append(vs.asStringValue()); String vsd = b.length() > 0 ? " where the codes are in the value sets ("+b.toString()+")" : ""; String system = cc.getSystem(); if (cc.hasConcept()) return Integer.toString(cc.getConcept().size())+" codes from "+system+vsd; if (cc.hasFilter()) { String s = ""; for (ConceptSetFilterComponent f : cc.getFilter()) { if (!Utilities.noString(s)) s = s + " & "; s = s + f.getProperty()+" "+f.getOp().toCode()+" "+f.getValue(); } return "from "+system+" where "+s+vsd; } return "All codes from "+system+vsd; }
return (Type) value; else if (value instanceof UriType) return new StringType(((UriType) value).asStringValue()); break; case TEXT: if (value instanceof StringType) return (Type) value; break;