use of org.hl7.fhir.definitions.model.SearchParameterDefn in project kindling by HL7.
the class PageProcessor method getAbstractSearch.
private String getAbstractSearch(ResourceDefn resource, String searchAdditions) {
if (resource.getSearchParams().size() == 0)
return "";
else {
StringBuilder b = new StringBuilder();
b.append("<h2>Search Parameters</h2>\r\n");
b.append("<p>Common search parameters defined by this resource. See <a href=\"search.html\">Searching</a> for more information about searching in REST, messaging, and services.</p>\r\n");
b.append("<table class=\"list\">\r\n");
b.append("<tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Paths</b></td></tr>\r\n");
List<String> names = new ArrayList<String>();
names.addAll(resource.getSearchParams().keySet());
Collections.sort(names);
for (String name : names) {
SearchParameterDefn p = resource.getSearchParams().get(name);
b.append("<tr><td>").append(p.getCode()).append("</td><td><a href=\"search.html#").append(p.getType()).append("\">").append(p.getType()).append("</a></td><td>").append(Utilities.escapeXml(p.getDescription())).append("</td><td>").append(presentPaths(p.getPaths())).append(p.getType() == SearchType.reference ? p.getTargetTypesAsText() : "").append("</td></tr>\r\n");
}
b.append(searchAdditions);
b.append("</table>\r\n");
return b.toString();
}
}
use of org.hl7.fhir.definitions.model.SearchParameterDefn in project kindling by HL7.
the class PageProcessor method buildCircularReferenceList.
private void buildCircularReferenceList(StringBuilder b, String s, ElementDefn t, ResourceDefn rd, Boolean hierarchy) {
if (t.getHierarchy() == hierarchy)
for (TypeRef tr : t.getTypes()) {
if (tr.getName().equals("Reference") || tr.getName().equals("canonical"))
for (String p : tr.getParams()) {
if (s.equals(p)) {
b.append("<li><a href=\"" + s.toLowerCase() + "-definitions.html#" + t.getPath() + "\">");
b.append(t.getPath());
b.append("</a>");
boolean first = true;
for (String spn : sorted(rd.getSearchParams().keySet())) {
SearchParameterDefn sp = rd.getSearchParams().get(spn);
if (pointsAtElement(sp, t)) {
if (first) {
b.append(" (");
first = false;
} else
b.append(",");
b.append(sp.getCode());
}
}
if (!first)
b.append(")");
b.append("</li>");
}
}
}
for (ElementDefn e : t.getElements()) buildCircularReferenceList(b, s, e, rd, hierarchy);
}
use of org.hl7.fhir.definitions.model.SearchParameterDefn in project kindling by HL7.
the class PageProcessor method genSearchParams.
private void genSearchParams(StringBuilder b, List<SearchParameter> splist, String base) throws Exception {
List<SearchParameter> list = new ArrayList<SearchParameter>();
for (SearchParameter sp : splist) {
for (CodeType ct : sp.getBase()) if (ct.asStringValue().equals(base)) {
boolean found = false;
for (SearchParameter spt : list) if (spt == sp)
found = true;
if (!found)
list.add(sp);
}
}
Collections.sort(list, new SearchParameterListSorter());
if (list.size() > 0) {
StandardsStatus bss = definitions.getResourceByName(base).getStatus();
b.append("<tr><td colspan=\"5\" style=\"background-color: #dddddd\"><b><a href=\"" + base.toLowerCase() + ".html\">" + base + "</a><a name=\"" + base.toLowerCase() + "\"> </a></b>" + makeStandardsStatusRef(bss) + "</td></tr>\r\n");
for (SearchParameter sp : list) {
String ss = "";
StandardsStatus spss = ToolingExtensions.getStandardsStatus(sp);
if (spss != null && spss != bss)
ss = makeStandardsStatusRef(spss);
if (sp.getBase().size() > 1) {
SearchParameterDefn spd = definitions.getResourceByName(base).getSearchParams().get(sp.getCode());
b.append("<tr><td>" + sp.getCode() + ss + "</td><td><a href=\"search.html#" + sp.getType().toCode() + "\">" + sp.getType().toCode() + "</a></td><td>" + sp.getId() + "</td><td>" + processMarkdown("allsearchparams", spd.getDescription(), "") + "</td><td>" + Utilities.escapeXml(spd.getExpression()).replace(".", ".​") + "</td></tr>\r\n");
} else
b.append("<tr><td>" + sp.getCode() + ss + "</td><td><a href=\"search.html#" + sp.getType().toCode() + "\">" + sp.getType().toCode() + "</a></td><td>" + sp.getId() + "</td><td>" + processMarkdown("allsearchparams", sp.getDescription(), "") + "</td><td>" + Utilities.escapeXml(sp.getExpression()).replace(".", ".​") + "</td></tr>\r\n");
}
}
}
use of org.hl7.fhir.definitions.model.SearchParameterDefn in project kindling by HL7.
the class OldSpreadsheetParser method copySearchParameters.
private void copySearchParameters(ResourceDefn resource) {
if (!resource.isInterface()) {
ResourceDefn t2 = definitions.getBaseResources().get(template.getRoot().typeCode());
if (t2 != null && t2.isInterface()) {
for (SearchParameterDefn sps : t2.getSearchParams().values()) {
if (sps.getPaths().size() == 0 || hasPath(resource, sps.getPaths().get(0))) {
SearchParameterDefn spt = new SearchParameterDefn(sps, t2.getName(), resource.getName(), templateTitle, resource.getName(), resource.getStatus());
resource.getSearchParams().put(spt.getCode(), spt);
}
}
}
for (SearchParameterDefn sps : template.getSearchParams().values()) {
if (sps.getPaths().size() == 0 || hasPath(resource, sps.getPaths().get(0))) {
SearchParameterDefn spt = new SearchParameterDefn(sps, template.getName(), resource.getName(), templateTitle, resource.getName(), resource.getStatus());
resource.getSearchParams().put(spt.getCode(), spt);
}
}
}
}
use of org.hl7.fhir.definitions.model.SearchParameterDefn in project kindling by HL7.
the class SourceParser method convertToExpression.
private String convertToExpression(ResourceDefn rd, List<String> pn, Set<String> targets, SearchParameterDefn sp) throws Exception {
StringBuilder b = new StringBuilder();
boolean first = true;
for (String p : pn) {
StringBuilder bp = new StringBuilder();
ElementDefn ed;
List<ElementDefn> trace = new ArrayList<ElementDefn>();
if (p.startsWith(rd.getName() + ".")) {
ed = rd.getRoot().getElementByName(p, true, definitions, "search parameter generation", true, trace);
} else if (p.startsWith("{{name}}.")) {
ed = rd.getRoot().getElementByName(p.replace("{{name}}", rd.getName()), true, definitions, "search parameter generation", true, trace);
} else
throw new Exception("huh?");
if (ed == null)
throw new Exception("not found: " + p);
for (ElementDefn t : trace) {
if (t.getStandardsStatus() != null && t.getStandardsStatus().isLowerThan(sp.getStandardsStatus()))
sp.setStandardsStatus(t.getStandardsStatus(), t.getNormativeVersion(rd));
try {
if (definitions.hasPrimitiveType(t.typeCodeNoParams())) {
sp.setStandardsStatus(StandardsStatus.NORMATIVE, t.getNormativeVersion(rd));
} else if (Utilities.noString(t.typeCode())) {
// nothing, this is part of the resource.
} else if (t.getTypes().size() == 1 && !t.getTypes().get(0).getName().startsWith("@")) {
TypeDefn tt = definitions.getElementDefn(t.typeCodeNoParams());
if (tt.getStandardsStatus() != null && tt.getStandardsStatus().isLowerThan(sp.getStandardsStatus())) {
sp.setStandardsStatus(tt.getStandardsStatus(), t.getNormativeVersion(rd));
}
}
} catch (Exception e) {
// nothing
}
}
if (ed.getName().endsWith("[x]"))
if (p.endsWith("[x]"))
bp.append(p.substring(0, p.length() - 3));
else {
int lp = p.lastIndexOf(".") + ed.getName().length() - 2;
String tn = p.substring(lp);
if (definitions.hasPrimitiveType(Utilities.uncapitalize(tn)))
bp.append("(" + p.substring(0, lp) + " as " + Utilities.uncapitalize(tn) + ")");
else
bp.append("(" + p.substring(0, lp) + " as " + tn + ")");
}
else
bp.append(p);
if (!targets.isEmpty() && !matchesElementDefinition(targets, ed.getTypes())) {
bp.append(".where(");
boolean innerFirst = true;
for (String t : targets) {
if (innerFirst)
innerFirst = false;
else
bp.append(" or ");
bp.append("resolve() is " + t);
}
bp.append(")");
}
if (first)
first = false;
else
b.append(" | ");
b.append(bp.toString());
}
return b.toString();
}
Aggregations