Search in sources :

Example 36 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method rrHeader.

private String rrHeader(String mode) {
    StringBuilder b = new StringBuilder();
    b.append("<ul class=\"nav nav-tabs\">");
    b.append(makeHeaderTab("RelatedResource", "relatedartifact.html", mode == null || "base".equals(mode)));
    b.append(makeHeaderTab("Examples", "relatedartifact-examples.html", mode == null || "examples".equals(mode)));
    b.append(makeHeaderTab("Detailed Descriptions", "relatedartifact-definitions.html", mode == null || "definitions".equals(mode)));
    b.append(makeHeaderTab("Mappings", "relatedartifact-mappings.html", mode == null || "mappings".equals(mode)));
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 37 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class ExampleInspector method fetch.

@Override
public Element fetch(IResourceValidator validator, Object appContext, String url) throws IOException, FHIRException {
    String[] parts = url.split("\\/");
    if (parts.length == 2 && definitions.hasResource(parts[0])) {
        ResourceDefn r = definitions.getResourceByName(parts[0]);
        for (Example e : r.getExamples()) {
            if (e.getElement() == null && e.hasXml()) {
                e.setElement(new org.hl7.fhir.r5.elementmodel.XmlParser(context).parse(e.getXml()));
                if (e.getElement().getProperty().getStructure().getBaseDefinition().contains("MetadataResource")) {
                    String urle = e.getElement().getChildValue("url");
                    String v = e.getElement().getChildValue("url");
                    if (urle != null && urle.startsWith("http://hl7.org/fhir") && !version.toCode().equals(v)) {
                        e.getElement().setChildValue("version", version.toCode());
                    }
                }
            }
            if (e.getElement() != null) {
                if (e.getElement().fhirType().equals("Bundle")) {
                    for (Base b : e.getElement().listChildrenByName("entry")) {
                        if (b.getChildByName("resource").hasValues()) {
                            Element res = (Element) b.getChildByName("resource").getValues().get(0);
                            if (res.fhirType().equals(parts[0]) && parts[1].equals(res.getChildValue("id"))) {
                                return res;
                            }
                        }
                    }
                } else if (e.getElement().fhirType().equals(parts[0]) && e.getId().equals(parts[1])) {
                    return e.getElement();
                }
            }
        }
        try {
            if (parts[0].equals("StructureDefinition"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(StructureDefinition.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("OperationDefinition"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(OperationDefinition.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("SearchParameter"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(SearchParameter.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("ValueSet"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(ValueSet.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
            if (parts[0].equals("CodeSystem"))
                return new ObjectConverter(context).convert(context.fetchResourceWithException(CodeSystem.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
        } catch (Exception e) {
            return null;
        }
        return null;
    } else
        return null;
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ObjectConverter(org.hl7.fhir.r5.elementmodel.ObjectConverter) Example(org.hl7.fhir.definitions.model.Example) Element(org.hl7.fhir.r5.elementmodel.Element) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Base(org.hl7.fhir.r5.model.Base) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) ValidationException(org.everit.json.schema.ValidationException) MalformedURLException(java.net.MalformedURLException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 38 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class CDAGenerator method buildInfrastructureRoot.

private void buildInfrastructureRoot() throws DefinitionException {
    StructureDefinition sd = new StructureDefinition();
    sd.setId("InfrastructureRoot");
    sd.setUrl("http://hl7.org/fhir/cda/StructureDefinition/InfrastructureRoot");
    library.put(sd.getUrl(), sd);
    sd.setName("Base Type for all classes in the CDA structure");
    sd.setTitle("InfrastructureRoot");
    sd.setStatus(PublicationStatus.ACTIVE);
    sd.setExperimental(false);
    sd.setPublisher("HL7");
    sd.setDescription("Defines the base elements and attributes on all CDA elements (other than data types)");
    sd.setKind(StructureDefinitionKind.LOGICAL);
    sd.setType(sd.getUrl());
    sd.setAbstract(true);
    sd.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:v3"));
    sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/ANY");
    sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
    ElementDefinition edb = new ElementDefinition();
    edb.setPath(sd.getId());
    seePath(edb);
    edb.setMin(1);
    edb.setMax("*");
    edb.addType().setCode("Element");
    sd.getDifferential().getElement().add(edb);
    ElementDefinition ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.realmCode");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("*");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of realm-specific constraints. The value of this attribute identifies the realm in question");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CS");
    sd.getDifferential().getElement().add(ed);
    ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.typeId");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("1");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of constraints defined in an HL7-specified message type. This might be a common type (also known as CMET in the messaging communication environment), or content included within a wrapper. The value of this attribute provides a unique identifier for the type in question.");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
    sd.getDifferential().getElement().add(ed);
    ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.templateId");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("*");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of a set of template-defined constraints. The value of this attribute provides a unique identifier for the templates in question");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
    sd.getDifferential().getElement().add(ed);
    new ProfileUtilities(null, null, null).setIds(sd, true);
    structures.add(sd);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) UriType(org.hl7.fhir.r5.model.UriType)

Example 39 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class HTMLLinkChecker method check.

private void check(XhtmlNode node, String href, String base, String source) throws FileNotFoundException, Exception {
    if (href == null)
        throw new Exception("no ref at " + node.allText());
    if (href.startsWith("http:") || href.startsWith("https:") || href.startsWith("ftp:") || href.startsWith("mailto:"))
        return;
    String path = href;
    String anchor = null;
    if (href.contains("#")) {
        path = href.substring(0, href.indexOf("#"));
        anchor = href.substring(href.indexOf("#") + 1);
    }
    Entry e;
    if (!Utilities.noString(path)) {
        if (href.endsWith("qa.html") || href.endsWith(".epub.zip"))
            return;
        if ("self-link".equals(node.getAttribute("class")))
            return;
        String target = collapse(base, path, source);
        if (target.endsWith(".xml") || target.endsWith(".json") || target.endsWith(".jsonld") || target.endsWith(".xsd") || target.endsWith(".shex") || target.endsWith(".txt") || target.endsWith(".sch") || target.endsWith(".pdf") || target.endsWith(".epub")) {
            if (!(new File(Utilities.path(page.getFolders().dstDir, target)).exists()))
                reportError(base, "Broken Link (1) in " + base + ": '" + href + "' not found at \"" + Utilities.path(page.getFolders().dstDir, target) + "\" (" + node.allText() + ")");
            node.setAttribute("href", webPath + "/" + target.replace(File.separatorChar, '/'));
            e = null;
        } else if (externals.contains(target)) {
            node.setAttribute("href", webPath + "/" + target.replace(File.separatorChar, '/'));
            e = null;
        } else {
            e = getEntryForFile(target, source);
            if (e == null) {
                if (// we can't check those links
                href.startsWith("v2/") || href.startsWith("v3/"))
                    return;
                if (target.endsWith(".zip") || target.endsWith(".ttl") || target.endsWith(".jar") || target.endsWith(".cfm") || target.endsWith(".tgz") || target.endsWith(".xlsx"))
                    return;
                reportError(base, "Broken Link (2) in " + base + ": '" + href + "' not found at \"" + target + "\"(" + node.allText() + ")");
                return;
            } else if (!e.include) {
                node.setAttribute("href", webPath + "/" + node.getAttribute("href"));
            }
        }
    } else
        e = getEntryForFile(base, source);
    if (Utilities.noString(anchor)) {
    // if (e == null) - need to enable this an fix everything it finds
    // reportError("Broken Link in "+base+": '"+href+"' anchor not found ("+node.allText()+")");
    } else {
        if (e != null) {
            if (!e.checked)
                check(e);
        // td        if (!e.anchors.contains(anchor))
        // td          reportError("Broken Link in "+base+": '"+href+"' anchor not found ("+node.allText()+")");
        }
    }
}
Also used : File(java.io.File) TextFile(org.hl7.fhir.utilities.TextFile) FileNotFoundException(java.io.FileNotFoundException)

Example 40 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method profileHeader.

// private String resourcesHeader(String n, String mode) {
// if (n.contains("-"))
// n = n.substring(0, n.indexOf('-'));
// StringBuilder b = new StringBuilder();
// b.append("<div class=\"navtop\">");
// b.append("<ul class=\"navtop\"><li class=\"spacerleft\"><span>&nbsp;</span></li>");
// if (mode == null || mode.equals("content"))
// b.append("<li class=\"selected\"><span>Content</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+".html\">Content</a></span></li>");
// if ("definitions".equals(mode))
// b.append("<li class=\"selected\"><span>Detailed Descriptions</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-definitions.html\">Detailed Descriptions</a></span></li>");
// b.append("<li class=\"spacerright\" style=\"width: 270px\"><span>&nbsp;</span></li>");
// b.append("</ul></div>\r\n");
// return b.toString();
// }
// private String formatsHeader(String n, String mode) {
// if (n.contains("-"))
// n = n.substring(0, n.indexOf('-'));
// StringBuilder b = new StringBuilder();
// b.append("<div class=\"navtop\">");
// b.append("<ul class=\"navtop\"><li class=\"spacerleft\"><span>&nbsp;</span></li>");
// if (mode == null || mode.equals("content"))
// b.append("<li class=\"selected\"><span>Content</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+".html\">Content</a></span></li>");
// if ("examples".equals(mode))
// b.append("<li class=\"selected\"><span>Examples</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-examples.html\">Examples</a></span></li>");
// if ("definitions".equals(mode))
// b.append("<li class=\"selected\"><span>Detailed Descriptions</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-definitions.html\">Detailed Descriptions</a></span></li>");
// b.append("<li class=\"spacerright\" style=\"width: 270px\"><span>&nbsp;</span></li>");
// b.append("</ul></div>\r\n");
// return b.toString();
// }
private String profileHeader(String n, String mode, boolean hasExamples) {
    StringBuilder b = new StringBuilder();
    if (n.endsWith(".xml"))
        n = n.substring(0, n.length() - 4);
    b.append("<ul class=\"nav nav-tabs\">");
    b.append(makeHeaderTab("Content", n + ".html", mode == null || "base".equals(mode)));
    if (hasExamples)
        b.append(makeHeaderTab("Examples", n + "-examples.html", mode == null || "examples".equals(mode)));
    b.append(makeHeaderTab("Detailed Descriptions", n + "-definitions.html", "definitions".equals(mode)));
    b.append(makeHeaderTab("Mappings", n + "-mappings.html", "mappings".equals(mode)));
    // if (!isDict && !n.equals("elementdefinition-de")) // todo: do this properly
    // b.append(makeHeaderTab("HTML Form", n+"-questionnaire.html", "questionnaire".equals(mode)));
    b.append(makeHeaderTab("XML", n + ".profile.xml.html", "xml".equals(mode)));
    b.append(makeHeaderTab("JSON", n + ".profile.json.html", "json".equals(mode)));
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Aggregations

ArrayList (java.util.ArrayList)324 FHIRException (org.hl7.fhir.exceptions.FHIRException)177 Base (org.hl7.fhir.r4b.model.Base)87 Base (org.hl7.fhir.r5.model.Base)87 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)76 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)70 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)66 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)64 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)55 NotImplementedException (org.apache.commons.lang3.NotImplementedException)47 Base (org.hl7.fhir.dstu2016may.model.Base)47 UcumException (org.fhir.ucum.UcumException)43 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)41 Base (org.hl7.fhir.dstu2.model.Base)40 BigDecimal (java.math.BigDecimal)39 IOException (java.io.IOException)37 ParserBase (org.hl7.fhir.dstu2016may.metamodel.ParserBase)34 FileOutputStream (java.io.FileOutputStream)29 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)28 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)28