Search in sources :

Example 36 with StructureDefinition

use of org.hl7.fhir.r4b.model.StructureDefinition in project kindling by HL7.

the class PageProcessor method genImplementationList.

private String genImplementationList(ResourceDefn logical) throws FHIRException {
    String url = logical.getMappingUrl();
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"lines\">\r\n");
    for (String s : sorted(definitions.getResources().keySet())) {
        ResourceDefn rd = definitions.getResourceByName(s);
        StructureDefinition sd = rd.getProfile();
        String code = null;
        for (StructureDefinitionMappingComponent m : sd.getMapping()) {
            if (m.getUri().equals(url))
                code = m.getIdentity();
        }
        if (code != null) {
            if (hasLogicalMapping(sd, logical, code)) {
                b.append(" <tr>\r\n");
                b.append("  <td><a href=\"" + rd.getName().toLowerCase() + ".html\">" + rd.getName() + "</a>&nbsp;&nbsp;&nbsp;&nbsp;</td>\r\n");
                b.append("  <td><a href=\"" + rd.getName().toLowerCase() + "-mappings.html#" + url + "\">Mappings</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\r\n");
                b.append("  <td><a href=\"" + rd.getName().toLowerCase() + "-examples.html\">Examples</a></td>\r\n");
                b.append(" </tr>\r\n");
            }
        }
    }
    b.append("</table>");
    return b.toString();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) StructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 37 with StructureDefinition

use of org.hl7.fhir.r4b.model.StructureDefinition in project kindling by HL7.

the class PageProcessor method genNSList.

private String genNSList() throws Exception {
    StringBuilder b = new StringBuilder();
    b.append("<p>Redirects on this page:</p>\r\n");
    b.append("<ul>\r\n");
    b.append(" <li>Resources</li>\r\n");
    b.append(" <li>Data Types</li>\r\n");
    b.append(" <li>Code Systems</li>\r\n");
    b.append(" <li>Value Sets</li>\r\n");
    b.append(" <li>Extensions</li>\r\n");
    b.append(" <li>Profiles</li>\r\n");
    b.append(" <li>Naming Systems</li>\r\n");
    b.append(" <li>Examples</li>\r\n");
    b.append(" <li>Compartments</li>\r\n");
    b.append(" <li>Data Elements</li>\r\n");
    b.append(" <li>Search Parameters</li>\r\n");
    b.append(" <li>Implementation Guides</li>\r\n");
    b.append(" <li>SIDs</li>\r\n");
    b.append(" <li>Others From publish.ini</li>\r\n");
    b.append("</ul>\r\n");
    b.append("<table class=\"grid\">\r\n");
    b.append(" <tr><td><b>URL</b></td><td><b>Thing</b></td><td><b>Page</b></td></tr>");
    for (String n : definitions.sortedResourceNames()) definitions.addNs("http://hl7.org/fhir/" + n, n + " Resource", n.toLowerCase() + ".html");
    for (String n : definitions.getTypes().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (String n : definitions.getPrimitives().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Primitive Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (String n : definitions.getConstraints().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type Profile " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (String n : definitions.getInfrastructure().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
    for (CodeSystem cs : getCodeSystems().getList()) if (cs != null && cs.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(cs.getUrl(), "CodeSystem " + cs.getName(), cs.getUserString("path"));
    for (ValueSet vs : getValueSets().getList()) if (vs.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(vs.getUrl(), "ValueSet " + vs.present(), vs.getUserString("path"));
    for (ConceptMap cm : getConceptMaps().getList()) if (cm.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(cm.getUrl(), "Concept Map" + cm.getName(), cm.getUserString("path"));
    for (StructureDefinition sd : profiles.getList()) if (sd.getUrl().startsWith("http://hl7.org/fhir") && !definitions.getResourceTemplates().containsKey(sd.getName()))
        definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) if (sd.getUrl().startsWith("http://hl7.org/fhir"))
        definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
    for (NamingSystem nss : definitions.getNamingSystems()) {
        String url = null;
        definitions.addNs("http://hl7.org/fhir/NamingSystem/" + nss.getId(), "System " + nss.getName(), nss.getUserString("path"));
        for (NamingSystemUniqueIdComponent t : nss.getUniqueId()) {
            if (t.getType() == NamingSystemIdentifierType.URI)
                url = t.getValue();
        }
        if (url != null && url.startsWith("http://hl7.org/fhir"))
            definitions.addNs(url, "System " + nss.getName(), nss.getUserString("path"));
    }
    for (String n : ini.getPropertyNames("redirects")) {
        String[] parts = ini.getStringProperty("redirects", n).split("\\;");
        definitions.addNs(n, "System " + parts[0], parts[1]);
    }
    for (ImplementationGuideDefn ig : definitions.getIgs().values()) {
        if (!ig.isCore()) {
            definitions.addNs("http://hl7.org/fhir/ImplementationGuide/" + ig.getCode(), ig.getName(), ig.getHomePage());
            definitions.addNs("http://hl7.org/fhir/" + ig.getCode(), ig.getName(), ig.getHomePage());
        }
    }
    for (Compartment t : definitions.getCompartments()) {
        definitions.addNs(t.getUri(), t.getName(), "compartmentdefinition.html#" + t.getName());
    }
    List<String> list = new ArrayList<String>();
    list.addAll(definitions.getRedirectList().keySet());
    Collections.sort(list);
    for (String url : list) {
        NamespacePair p = definitions.getRedirectList().get(url);
        b.append(" <tr><td>" + Utilities.escapeXml(url) + "</td><td>" + hsplt(Utilities.escapeXml(p.desc)) + "</td><td><a href=\"" + p.page + "\">" + hsplt(Utilities.escapeXml(p.page)) + "</a></td></tr>\r\n");
    }
    b.append("</table>\r\n");
    b.append("<p>" + Integer.toString(list.size()) + " Entries</p>\r\n");
    return b.toString();
}
Also used : NamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) Compartment(org.hl7.fhir.definitions.model.Compartment) ArrayList(java.util.ArrayList) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) NamespacePair(org.hl7.fhir.definitions.model.Definitions.NamespacePair) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) ValueSet(org.hl7.fhir.r5.model.ValueSet)

Example 38 with StructureDefinition

use of org.hl7.fhir.r4b.model.StructureDefinition 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 39 with StructureDefinition

use of org.hl7.fhir.r4b.model.StructureDefinition in project kindling by HL7.

the class CDAGenerator method finish.

private void finish() throws FileNotFoundException, IOException {
    StringBuilder b = new StringBuilder();
    for (StructureDefinition sd : structures) {
        new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(target, sd.getId() + ".xml")), sd);
        b.append("   <resource>\r\n" + "     <purpose value=\"logical\"/>\r\n" + "     <name value=\"" + sd.getName() + "\"/>\r\n" + "     <sourceUri value=\"cda\\cda-logical-" + sd.getId() + ".xml\"/>\r\n" + "   </resource>\r\n");
    }
    TextFile.stringToFile(b.toString(), Utilities.path(target, "ig-template.xml"));
// dumpPaths();
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FileOutputStream(java.io.FileOutputStream)

Example 40 with StructureDefinition

use of org.hl7.fhir.r4b.model.StructureDefinition 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)

Aggregations

ArrayList (java.util.ArrayList)307 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)226 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)158 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)144 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)105 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)98 IOException (java.io.IOException)91 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)91 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)87 StructureDefinition (org.hl7.fhir.r4.model.StructureDefinition)83 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)70 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)69 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)67 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)58 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)56 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)50 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)49 ProfileUtilities (org.hl7.fhir.r5.conformance.ProfileUtilities)46 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)46