Search in sources :

Example 41 with SearchParameter

use of org.hl7.fhir.r4b.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();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) ArrayList(java.util.ArrayList) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) SearchParameter(org.hl7.fhir.r5.model.SearchParameter)

Example 42 with SearchParameter

use of org.hl7.fhir.r4b.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(".", ".&#8203;") + "</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(".", ".&#8203;") + "</td></tr>\r\n");
        }
    }
}
Also used : SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r5.model.CodeType) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus)

Example 43 with SearchParameter

use of org.hl7.fhir.r4b.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();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) Profile(org.hl7.fhir.definitions.model.Profile)

Example 44 with SearchParameter

use of org.hl7.fhir.r4b.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());
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) StringType(org.hl7.fhir.r5.model.StringType) Bundle(org.hl7.fhir.r5.model.Bundle) SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) FileOutputStream(java.io.FileOutputStream) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CodeType(org.hl7.fhir.r5.model.CodeType) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) File(java.io.File) CompositeDefinition(org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition)

Example 45 with SearchParameter

use of org.hl7.fhir.r4b.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;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) CSFile(org.hl7.fhir.utilities.CSFile) File(java.io.File) TextFile(org.hl7.fhir.utilities.TextFile) Profile(org.hl7.fhir.definitions.model.Profile)

Aggregations

SearchParameter (org.hl7.fhir.r5.model.SearchParameter)32 FHIRException (org.hl7.fhir.exceptions.FHIRException)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 ArrayList (java.util.ArrayList)12 File (java.io.File)9 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 SearchParameter (org.hl7.fhir.r4b.model.SearchParameter)9 CodeType (org.hl7.fhir.r5.model.CodeType)9 HashSet (java.util.HashSet)8 FileOutputStream (java.io.FileOutputStream)7 XmlParser (org.hl7.fhir.r5.formats.XmlParser)7 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)6 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 ImplementationGuide (org.hl7.fhir.r5.model.ImplementationGuide)6 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)6 ConstraintStructure (org.hl7.fhir.definitions.model.ConstraintStructure)5 Example (org.hl7.fhir.definitions.model.Example)5