private String getSystemType(String url) { if (url.startsWith("http://hl7.org/fhir/StructureDefinition/")) { String code = url.substring(40); if (Utilities.existsInList(code, "string", "boolean", "integer", "decimal", "dateTime", "time", "Quantity")) return FP_NS+Utilities.capitalize(code); } return null; }
private String generateInnerType(List<StringBuilder> list, StructureDefinition sd, String name, ElementDefinition child, String mode) throws IOException { if (child.hasUserData(INNER_TYPE_NAME+"."+mode)) return child.getUserString(INNER_TYPE_NAME+"."+mode); String typeName = name+Utilities.capitalize(tail(child.getPath(), false)); child.setUserData(INNER_TYPE_NAME+"."+mode, typeName); StringBuilder b = new StringBuilder(); list.add(b); b.append(mode); b.append(" "); b.append(typeName); b.append(" {\r\n"); generateProperties(list, b, typeName, sd, child, mode); b.append("}"); b.append("\r\n"); b.append("\r\n"); return typeName; }
private List<Base> opIs(List<Base> left, List<Base> right) { List<Base> result = new ArrayList<Base>(); if (left.size() != 1 || right.size() != 1) result.add(new BooleanType(false).noExtensions()); else { String tn = convertToString(right); if (left.get(0) instanceof org.hl7.fhir.r4.elementmodel.Element) result.add(new BooleanType(left.get(0).hasType(tn)).noExtensions()); else if ((left.get(0) instanceof Element) && ((Element) left.get(0)).isDisallowExtensions()) result.add(new BooleanType(Utilities.capitalize(left.get(0).fhirType()).equals(tn)).noExtensions()); else result.add(new BooleanType(left.get(0).hasType(tn)).noExtensions()); } return result; }
private String validateQuestionnaireResponseItemType(List<ValidationMessage> errors, Element element, NodeStack stack, String... types) { List<Element> values = new ArrayList<Element>(); element.getNamedChildrenWithWildcard("value[x]", values); if (values.size() > 0) { NodeStack ns = stack.push(values.get(0), -1, null, null); CommaSeparatedStringBuilder l = new CommaSeparatedStringBuilder(); for (String s : types) { l.append(s); if (values.get(0).getName().equals("value"+Utilities.capitalize(s))) return(s); } if (types.length == 1) rule(errors, IssueType.STRUCTURE, values.get(0).line(), values.get(0).col(), ns.getLiteralPath(), false, "Answer value must be of type "+types[0]); else rule(errors, IssueType.STRUCTURE, values.get(0).line(), values.get(0).col(), ns.getLiteralPath(), false, "Answer value must be one of the types "+l.toString()); } return null; }
public boolean hasType(String n) { String t = ProfiledType.ns(n); if (typesContains(t)) return true; if (Utilities.existsInList(n, "boolean", "string", "integer", "decimal", "Quantity", "dateTime", "time", "ClassInfo", "SimpleTypeInfo")) { t = FP_NS+Utilities.capitalize(n); if (typesContains(t)) return true; } return false; }
private String validateQuestionnaireResponseItemType(List<ValidationMessage> errors, Element element, NodeStack stack, String... types) { List<Element> values = new ArrayList<Element>(); element.getNamedChildrenWithWildcard("value[x]", values); if (values.size() > 0) { NodeStack ns = stack.push(values.get(0), -1, null, null); CommaSeparatedStringBuilder l = new CommaSeparatedStringBuilder(); for (String s : types) { l.append(s); if (values.get(0).getName().equals("value"+Utilities.capitalize(s))) return(s); } if (types.length == 1) rule(errors, IssueType.STRUCTURE, values.get(0).line(), values.get(0).col(), ns.getLiteralPath(), false, "Answer value must be of type "+types[0]); else rule(errors, IssueType.STRUCTURE, values.get(0).line(), values.get(0).col(), ns.getLiteralPath(), false, "Answer value must be one of the types "+l.toString()); } return null; }
private String getName() { if ((instance instanceof Resource)) return instance.fhirType(); else if (!(instance instanceof Element) || ((Element)instance).isDisallowExtensions()) return Utilities.capitalize(instance.fhirType()); else return instance.fhirType(); } }
b.append(tail(child.getPath(), suffix)); if (suffix) b.append(Utilities.capitalize(typeDetails.getCode())); b.append(": "); b.append(n); b.append(tail(child.getPath(), suffix)); if (suffix) b.append(Utilities.capitalize(typeDetails.getCode())); if (!child.getMax().equals("1")) b.append(": [ElementBase]\r\n"); b.append(tail(child.getPath(), suffix)); if (suffix) b.append(Utilities.capitalize(typeDetails.getCode())); b.append(": "); if (!child.getMax().equals("1"))
public boolean hasType(Set<String> tn) { for (String n: tn) { String t = ProfiledType.ns(n); if (typesContains(t)) return true; if (Utilities.existsInList(n, "boolean", "string", "integer", "decimal", "Quantity", "dateTime", "time", "ClassInfo", "SimpleTypeInfo")) { t = FP_NS+Utilities.capitalize(n); if (typesContains(t)) return true; } } return false; } public String describe() {
private String validateQuestionnaireResponseItemType(List<ValidationMessage> errors, Element element, NodeStack stack, String... types) { List<Element> values = new ArrayList<Element>(); element.getNamedChildrenWithWildcard("value[x]", values); for (int i = 0; i < types.length; i++) { if (types[i].equals("text")) { types[i] = "string"; } } if (values.size() > 0) { NodeStack ns = stack.push(values.get(0), -1, null, null); CommaSeparatedStringBuilder l = new CommaSeparatedStringBuilder(); for (String s : types) { l.append(s); if (values.get(0).getName().equals("value"+Utilities.capitalize(s))) return(s); } if (types.length == 1) rule(errors, IssueType.STRUCTURE, values.get(0).line(), values.get(0).col(), ns.getLiteralPath(), false, "Answer value must be of type "+types[0]); else rule(errors, IssueType.STRUCTURE, values.get(0).line(), values.get(0).col(), ns.getLiteralPath(), false, "Answer value must be one of the types "+l.toString()); } return null; }
return makeBoolean(n.equals(Utilities.capitalize(focus.get(0).fhirType()))); else return makeBoolean(false);
if (property.isChoice()) { for (TypeRefComponent type : property.getDefinition().getType()) { String eName = property.getName().substring(0, property.getName().length()-3) + Utilities.capitalize(type.getCode()); if (!ParserBase.isPrimitive(type.getCode()) && object.has(eName)) { parseChildComplex(path, object, context, processed, property, eName);
if (property.isChoice()) { for (TypeRefComponent type : property.getDefinition().getType()) { String eName = property.getName().substring(0, property.getName().length()-3) + Utilities.capitalize(type.getCode()); if (!isPrimitive(type.getCode()) && object.has(eName)) { parseChildComplex(path, object, context, processed, property, eName);
private void parseChildren(Turtle src, String path, TTLComplex object, Element context, boolean primitive) throws FHIRException { List<Property> properties = context.getProperty().getChildProperties(context.getName(), null); Set<String> processed = new HashSet<String>(); if (primitive) processed.add(FHIR_URI_BASE + "value"); // note that we do not trouble ourselves to maintain the wire format order here - we don't even know what it was anyway // first pass: process the properties for (Property property : properties) { if (property.isChoice()) { for (TypeRefComponent type : property.getDefinition().getType()) { String eName = property.getName().substring(0, property.getName().length()-3) + Utilities.capitalize(type.getCode()); parseChild(src, object, context, processed, property, path, getFormalName(property, eName)); } } else { parseChild(src, object, context, processed, property, path, getFormalName(property)); } } // second pass: check for things not processed if (policy != ValidationPolicy.NONE) { for (String u : object.getPredicates().keySet()) { if (!processed.contains(u)) { TTLObject n = object.getPredicates().get(u); logError(n.getLine(), n.getCol(), path, IssueType.STRUCTURE, "Unrecognised predicate '"+u+"'", IssueSeverity.ERROR); } } } }
return true; if (Utilities.existsInList(n, "boolean", "string", "integer", "decimal", "Quantity", "dateTime", "time", "ClassInfo", "SimpleTypeInfo")) { t = FP_NS+Utilities.capitalize(n); if (typesContains(t)) return true;
else if (value.isPrimitive()) { if (childForValue.property.getName().endsWith("[x]")) childForValue.name = name+Utilities.capitalize(value.fhirType()); childForValue.setValue(value.primitiveValue()); } else { childForValue.type = ve.getType(); if (childForValue.property.getName().endsWith("[x]")) childForValue.name = name+Utilities.capitalize(childForValue.type); else if (value.isResource()) { if (childForValue.elementProperty == null)
ext.getSnapshot().getElement().get(3).setFixed(new UriType(url)); ext.getSnapshot().getElement().set(4, ed.copy()); ext.getSnapshot().getElement().get(4).setPath("Extension.value"+Utilities.capitalize(ed.typeSummary())); return ext;
private String getFormalName(Element element) { String en = null; if (element.getSpecial() == null) { if (element.getProperty().getDefinition().hasBase()) en = element.getProperty().getDefinition().getBase().getPath(); } else if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY) en = "Bundle.entry.resource"; else if (element.getSpecial() == SpecialElement.BUNDLE_OUTCOME) en = "Bundle.entry.response.outcome"; else if (element.getSpecial() == SpecialElement.PARAMETER) en = element.getElementProperty().getDefinition().getPath(); else // CONTAINED en = "DomainResource.contained"; if (en == null) en = element.getProperty().getDefinition().getPath(); boolean doType = false; if (en.endsWith("[x]")) { en = en.substring(0, en.length()-3); doType = true; } if (doType || (element.getProperty().getDefinition().getType().size() > 1 && !allReference(element.getProperty().getDefinition().getType()))) en = en + Utilities.capitalize(element.getType()); return en; }
if ((prefix + Utilities.capitalize(t.getCode())).equals(ei.name)) type = t.getCode(); if (type == null) {
String name = tailDot(edc.getPath()); if (edc.getType().size() > 1) name = name + Utilities.capitalize(t.getCode()); QName qn = getQN(sd, edc, t.getCode(), true); String min = String.valueOf(edc.getMin());