Search in sources :

Example 96 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method getExampleByRef.

private Example getExampleByRef(String bundle) throws Exception {
    String[] parts = bundle.split("\\/");
    ResourceDefn r = definitions.getResourceByName(parts[0]);
    for (Example e : r.getExamples()) {
        if (e.getId().equals(parts[1]))
            return e;
    }
    throw new Exception("unable to resolve " + bundle);
}
Also used : Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 97 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method jsonToXhtml.

public void jsonToXhtml(String src, String dst, String name, String description, int level, String json, String pageType, String crumbTitle, ImplementationGuideDefn ig, ResourceDefn rd, WorkGroup wg) throws Exception {
    String n = new File(dst).getName();
    n = n.substring(0, n.length() - 10);
    json = "<div class=\"example\">\r\n<p>" + Utilities.escapeXml(description) + "</p>\r\n<pre class=\"json\">\r\n" + Utilities.escapeXml(json) + "\r\n</pre>\r\n</div>\r\n";
    String html = ("<%setlevel " + Integer.toString(level) + "%>" + TextFile.fileToString(folders.srcDir + "template-example-json.html")).replace("<%example%>", json);
    html = processPageIncludes(n + ".json.html", html, pageType, null, null, null, crumbTitle, ig, rd, wg);
    TextFile.stringToFile(html, dst);
    htmlchecker.registerExternal(dst);
}
Also used : IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Example 98 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method genDataTypeUsage.

private String genDataTypeUsage(String tn) {
    StringBuilder b = new StringBuilder();
    for (ElementDefn e : definitions.getTypes().values()) {
        if (usesType(e, tn)) {
            b.append(", <a href=\"").append(definitions.getSrcFile(e.getName()) + ".html#" + e.getName()).append("\">").append(e.getName()).append("</a>");
        }
    }
    List<String> resources = new ArrayList<String>();
    for (ResourceDefn e : definitions.getResources().values()) {
        if (usesType(e.getRoot(), tn)) {
            resources.add(e.getName());
        }
    }
    for (ResourceDefn e : definitions.getBaseResources().values()) {
        if (usesType(e.getRoot(), tn)) {
            resources.add(e.getName());
        }
    }
    Collections.sort(resources);
    for (String n : resources) b.append(", <a href=\"").append(definitions.getSrcFile(n) + ".html#" + n.toLowerCase()).append("\">").append(n).append("</a>");
    if (b.toString().length() < 2)
        return "(not used as yet)";
    String s = b.toString().substring(2);
    int i = s.lastIndexOf(", ");
    if (i > 1)
        s = s.substring(0, i) + " and" + s.substring(i + 1);
    return s;
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ArrayList(java.util.ArrayList) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 99 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.

the class PageProcessor method buildResListByMaturity.

private String buildResListByMaturity() throws FHIRException {
    List<String> res = new ArrayList<String>();
    for (ResourceDefn rd : definitions.getBaseResources().values()) res.add(rd.getFmmLevel() + ":" + rd.getName());
    for (ResourceDefn rd : definitions.getResources().values()) res.add(rd.getFmmLevel() + ":" + rd.getName());
    Collections.sort(res);
    StringBuilder b = new StringBuilder();
    for (int i = 5; i >= 0; i--) {
        b.append("<p><b>Level ");
        b.append(i);
        b.append("</b></p>\r\n<ul style=\"width: 90%; -moz-column-count: 4; -moz-column-gap: 10px; -webkit-column-count: 4; -webkit-column-gap: 10px; column-count: 4; column-gap: 10px\">\r\n");
        for (String rn : res) {
            if (rn.startsWith(Integer.toString(i))) {
                String r = rn.substring(2);
                ResourceDefn rd = definitions.getResourceByName(r);
                if (rd.getNormativePackage() != null || rd.getNormativeVersion() != null)
                    b.append("  <li><a title=\"[%resdesc " + r + "%]\" href=\"" + r.toLowerCase() + ".html\">" + r + "</a> <a href=\"versions.html#std-process\"  title=\"Normative Content\" class=\"normative-flag\">N</a></li>\r\n");
                else
                    b.append("  <li><a title=\"[%resdesc " + r + "%]\" href=\"" + r.toLowerCase() + ".html\">" + r + "</a></li>\r\n");
            }
        }
        b.append("</ul>\r\n");
    }
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 100 with ResourceDefn

use of org.hl7.fhir.definitions.model.ResourceDefn 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);
}
Also used : TypeRef(org.hl7.fhir.definitions.model.TypeRef) SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Aggregations

ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)75 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 ArrayList (java.util.ArrayList)38 FHIRException (org.hl7.fhir.exceptions.FHIRException)36 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)31 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)28 File (java.io.File)26 FileOutputStream (java.io.FileOutputStream)25 CSFile (org.hl7.fhir.utilities.CSFile)24 XmlParser (org.hl7.fhir.r5.formats.XmlParser)22 FileNotFoundException (java.io.FileNotFoundException)20 IOException (java.io.IOException)20 Example (org.hl7.fhir.definitions.model.Example)20 Profile (org.hl7.fhir.definitions.model.Profile)20 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)18 IniFile (org.hl7.fhir.utilities.IniFile)18 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)16 TransformerException (javax.xml.transform.TransformerException)15 TextFile (org.hl7.fhir.utilities.TextFile)15 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)14