use of org.hl7.fhir.r4.model.SearchParameter in project kindling by HL7.
the class PageProcessor method getPackageContent.
private String getPackageContent(Profile pack, String prefix) throws Exception {
StringBuilder s = new StringBuilder();
s.append("<table class=\"lines\">");
if (pack.getProfiles().size() > 0) {
s.append("<tr><td colspan=\"2\"><b>Profiles</b>: </td></tr>");
for (ConstraintStructure p : pack.getProfiles()) s.append("<tr><td><a href=\"").append(p.getId()).append(".html\">").append(Utilities.escapeXml(p.getTitle())).append("</a></td><td>").append(Utilities.escapeXml(p.getResource().getDescription())).append("</td></tr>");
}
if (pack.getExtensions().size() > 0) {
s.append("<tr><td colspan=\"2\"><b>Extensions</b>: </td></tr>");
for (StructureDefinition ed : pack.getExtensions()) s.append("<tr><td><a name=\"extension-").append(prefix + ed.getId()).append("\"> </a><a href=\"extension-").append(ed.getId().toLowerCase()).append(".html\">").append(Utilities.escapeXml(ed.getId())).append("</a></td><td><b>").append(Utilities.escapeXml(ed.getName())).append("</b> : ").append(processMarkdown(pack.getId(), ed.getDescription(), prefix)).append("</td></tr>");
}
if (pack.getExamples().size() > 0) {
s.append("<tr><td colspan=\"2\"><b>Examples</b>: </td></tr>");
for (Example ex : pack.getExamples()) s.append("<tr><td><a href=\"").append(ex.getTitle()).append(".html\">").append(Utilities.escapeXml(Utilities.changeFileExt(ex.getName(), ""))).append("</a></td><td>").append(processMarkdown(pack.getId(), ex.getDescription(), prefix)).append("</td></tr>");
}
s.append("</table>");
if (pack.getSearchParameters().size() > 0) {
// search parameters
StringBuilder b = new StringBuilder();
b.append("<a name=\"search\"> </a>\r\n");
b.append("<h3>Search Parameters</h3>\r\n");
b.append("<p>Search parameters defined by this package. See <a href=\"" + prefix + "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><td><b>Source</b></td></tr>\r\n");
List<String> names = new ArrayList<String>();
for (SearchParameter sp : pack.getSearchParameters()) names.add(sp.getName());
Collections.sort(names);
for (String name : names) {
SearchParameter p = null;
for (SearchParameter sp : pack.getSearchParameters()) if (name.equals(sp.getName()))
p = sp;
b.append("<tr><td>" + p.getName() + "</td><td><a href=\"" + prefix + "search.html#" + p.getType().toCode() + "\">" + p.getType().toCode() + "</a></td>" + "<td>" + Utilities.escapeXml(p.getDescription()) + "</td><td>" + (p.hasXpath() ? p.getXpath() : "") + (p.getType() == SearchParamType.REFERENCE && p.hasTarget() ? asText(p.getTarget()) : "") + "</td>" + "<td><a href=\"" + p.getId() + ".xml.html\">XML</a> / <a href=\"" + p.getId() + ".json.html\">JSON</a></td></tr>\r\n");
}
b.append("</table>\r\n");
s.append(b.toString());
}
return s.toString();
}
use of org.hl7.fhir.r4.model.SearchParameter 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.r4.model.SearchParameter in project kindling by HL7.
the class PageProcessor method produceSearchExtensions.
private String produceSearchExtensions(ResourceDefn resource) {
int count = 0;
Map<String, SearchParameter> map = new HashMap<String, SearchParameter>();
for (Profile cp : getDefinitions().getPackList()) {
addSearchParams(map, cp, resource.getName());
}
for (Profile cp : resource.getConformancePackages()) {
addSearchParams(map, cp, resource.getName());
}
StringBuilder b = new StringBuilder();
for (String s : sorted(map.keySet())) {
SearchParameter sp = map.get(s);
count++;
b.append("<tr>" + "<td>" + sp.getCode() + "</td>" + "<td><a href=\"search.html#" + sp.getType().toCode() + "\">" + sp.getType().toCode() + "</a></td>" + "<td>" + Utilities.escapeXml(sp.getDescription()) + "<br/>" + "<b>Expression:</b> " + Utilities.escapeXml(sp.getExpression()) + "</td></tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Search Extensions defined for this resource</td></tr>");
return b.toString();
}
use of org.hl7.fhir.r4.model.SearchParameter in project kindling by HL7.
the class Regenerator method generateSearchParams.
private void generateSearchParams(String root, ResourceDefn r) throws FileNotFoundException, IOException {
Bundle bnd = new Bundle();
bnd.setId(r.getName() + "-search-params");
for (String s : sorted(r.getSearchParams().keySet())) {
SearchParameterDefn spd = r.getSearchParams().get(s);
SearchParameter sp = new SearchParameter();
sp.setId(r.getName() + "-" + spd.getCode());
bnd.addEntry().setResource(sp);
sp.setUrl("http://hl7.org/fhir/build/SearchParameter/" + sp.getId());
sp.setCode(spd.getCode());
sp.setDescription(spd.getDescription());
sp.setXpath(spd.getXPath());
switch(spd.getType()) {
case composite:
sp.setType(SearchParamType.COMPOSITE);
break;
case date:
sp.setType(SearchParamType.DATE);
break;
case number:
sp.setType(SearchParamType.NUMBER);
break;
case quantity:
sp.setType(SearchParamType.QUANTITY);
break;
case reference:
sp.setType(SearchParamType.REFERENCE);
break;
case special:
sp.setType(SearchParamType.SPECIAL);
break;
case string:
sp.setType(SearchParamType.STRING);
break;
case token:
sp.setType(SearchParamType.TOKEN);
break;
case uri:
sp.setType(SearchParamType.URI);
break;
}
sp.setXpathUsage(spd.getxPathUsage());
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(",");
for (String p : spd.getPaths()) {
b.append(p);
}
if (!Utilities.noString(b.toString())) {
sp.addExtension(BuildExtensions.EXT_PATH, new StringType(b.toString()));
}
sp.setExpression(spd.getExpression());
if (spd.hasManualTypes()) {
for (String t : sorted(spd.getManualTypes())) {
sp.addTarget(t);
}
}
if (spd.getStandardsStatus() != null) {
sp.addExtension(ToolingExtensions.EXT_STANDARDS_STATUS, new CodeType(spd.getStandardsStatus().toCode()));
}
for (CompositeDefinition c : spd.getComposites()) {
sp.addComponent().setExpression(c.getExpression()).setDefinition(c.getDefinition());
}
}
File fn = new File(Utilities.path(root, bnd.fhirType().toLowerCase() + "-" + bnd.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), bnd);
fn.setLastModified(r.getTimestamp());
}
use of org.hl7.fhir.r4.model.SearchParameter in project kindling by HL7.
the class ResourceParser method convertPack.
private Profile convertPack(ImplementationGuide ig, String id, WorkGroup wg) throws Exception {
Profile p = new Profile(id.substring(id.indexOf("-") + 1));
p.setTitle(ig.getTitle());
p.forceMetadata("id", ig.getId());
if (ig.hasName()) {
p.forceMetadata("name", ig.getName());
}
if (ig.hasPublisher()) {
p.forceMetadata("author.name", ig.getPublisher());
}
if (ig.hasExtension(BuildExtensions.EXT_CODE)) {
p.forceMetadata("code", BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_CODE));
}
if (ig.hasExtension(BuildExtensions.EXT_FMM_LEVEL)) {
p.forceMetadata("fmm", BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_FMM_LEVEL));
}
if (ig.hasDescription()) {
p.forceMetadata("description", ig.getDescription());
}
if (ig.hasStatus()) {
p.forceMetadata("status", ig.getStatus().toCode());
}
if (ig.hasVersion()) {
p.forceMetadata("version", ig.getVersion());
}
if (ig.hasTitle()) {
p.forceMetadata("display", ig.getTitle());
}
if (ig.hasExtension(BuildExtensions.EXT_WORKGROUP)) {
p.forceMetadata("workgroup", BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_WORKGROUP));
}
if (ig.hasDate()) {
p.forceMetadata("date", ig.getDateElement().primitiveValue());
}
if (ig.hasExperimental()) {
p.forceMetadata("Experimental", ig.getExperimentalElement().primitiveValue());
}
if (ig.hasExtension(BuildExtensions.EXT_INTRODUCTION)) {
p.setIntroduction(Utilities.path(folder, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_INTRODUCTION)));
}
if (ig.hasExtension(BuildExtensions.EXT_NOTES)) {
p.setNotes(Utilities.path(folder, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_NOTES)));
}
for (ImplementationGuideDefinitionResourceComponent res : ig.getDefinition().getResource()) {
String ref = res.getReference().getReference();
String type = ref.substring(0, ref.indexOf("/"));
String rid = ref.substring(ref.indexOf("/") + 1);
if ("StructureDefinition".equals(type)) {
StructureDefinition sd;
if (new File(Utilities.path(folder, "structuredefinition-extension-" + rid + ".xml")).exists()) {
sd = (StructureDefinition) parseXml("structuredefinition-extension-" + rid + ".xml");
sd.setUserData("path", "extension-" + sd.getId() + ".html");
p.getExtensions().add(sd);
context.cacheResource(sd);
} else {
ConstraintStructure tp = processProfile(rid, ig.getId().substring(ig.getId().indexOf("-") + 1), res, wg);
sd = tp.getResource();
sd.setUserData("path", sd.getId() + ".html");
p.getProfiles().add(tp);
}
sd.setUserData(ToolResourceUtilities.NAME_RES_IG, id);
sd.setVersion(version);
for (ElementDefinition ed : sd.getDifferential().getElement()) {
if (ed.hasBinding() && ed.getBinding().hasValueSet()) {
loadValueSet(ed.getBinding().getValueSet(), true);
}
}
} else if ("SearchParameter".equals(type)) {
SearchParameter sp = processSearchParameter(rid);
p.getSearchParameters().add(sp);
} else {
// example
p.getExamples().add(makeExample(res, ref, type, rid));
}
}
return p;
}
Aggregations