Search in sources :

Example 1 with NamingSystemUniqueIdComponent

use of org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent in project kindling by HL7.

the class Publisher method generateCodeSystemRegistry.

private void generateCodeSystemRegistry() throws FileNotFoundException, IOException, Exception {
    XmlParser xml = new XmlParser();
    xml.setOutputStyle(OutputStyle.PRETTY);
    Bundle bnd = (Bundle) xml.parse(new CSFileInputStream(Utilities.path(page.getFolders().srcDir, "namingsystem", "namingsystem-terminologies.xml")));
    for (BundleEntryComponent entry : bnd.getEntry()) {
        NamingSystem ns = (NamingSystem) entry.getResource();
        entry.setFullUrl("http://hl7.org/fhir/NamingSystem/" + ns.getId());
        String url = null;
        for (NamingSystemUniqueIdComponent t : ns.getUniqueId()) {
            if (t.getType() == NamingSystemIdentifierType.URI)
                url = t.getValue();
        }
        if (url != null) {
            if (url.startsWith("http://hl7.org/fhir"))
                page.getDefinitions().addNs(url, "System " + ns.getName(), "terminologies-systems.html#" + url);
            page.getDefinitions().addNs(entry.getFullUrl(), ns.getId(), "terminologies-systems.html#" + url);
        }
    }
    List<String> names = new ArrayList<String>();
    Set<String> urls = new HashSet<>();
    names.addAll(page.getCodeSystems().keys());
    Collections.sort(names);
    for (String n : names) {
        CodeSystem cs = page.getCodeSystems().get(n);
        if (cs != null && !urls.contains(cs.getUrl()) && cs.hasUrl() && !cs.getUrl().startsWith("http://terminology.hl7.org")) {
            urls.add(cs.getUrl());
            if (cs.hasName()) {
                NamingSystem ns = new NamingSystem();
                ns.setId(cs.getId());
                ns.setName(cs.getName());
                ns.setStatus(cs.getStatus());
                if (!ns.hasStatus())
                    ns.setStatus(PublicationStatus.DRAFT);
                ns.setKind(NamingSystemType.CODESYSTEM);
                ns.setPublisher(cs.getPublisher());
                for (ContactDetail c : cs.getContact()) {
                    ContactDetail nc = ns.addContact();
                    nc.setName(c.getName());
                    for (ContactPoint cc : c.getTelecom()) {
                        nc.getTelecom().add(cc);
                    }
                }
                ns.setDate(cs.getDate());
                if (!ns.hasDate())
                    ns.setDate(page.getGenDate().getTime());
                ns.setDescription(cs.getDescription());
                ns.addUniqueId().setType(NamingSystemIdentifierType.URI).setValue(cs.getUrl()).setPreferred(true);
                String oid = CodeSystemUtilities.getOID(cs);
                if (oid != null) {
                    if (oid.startsWith("urn:oid:"))
                        oid = oid.substring(8);
                    ns.addUniqueId().setType(NamingSystemIdentifierType.OID).setValue(oid).setPreferred(false);
                }
                ns.setUserData("path", cs.getUserData("path"));
                bnd.addEntry().setResource(ns).setFullUrl("http://hl7.org/fhir/" + ns.fhirType() + "/" + ns.getId());
            }
        }
    }
    xml.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.xml")), bnd);
    cloneToXhtml("namingsystem-terminologies", "Terminology Registry", false, "resource-instance:NamingSystem", "Terminology Registry", null, wg("vocab"));
    xml.setOutputStyle(OutputStyle.CANONICAL);
    xml.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.canonical.xml")), bnd);
    JsonParser json = new JsonParser();
    json.setOutputStyle(OutputStyle.PRETTY);
    json.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.json")), bnd);
    jsonToXhtml("namingsystem-terminologies", "Terminology Registry", TextFile.fileToString(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.json")), "resource-instance:NamingSystem", "Terminology Registry", null, wg("vocab"));
    json.setOutputStyle(OutputStyle.CANONICAL);
    json.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.canonical.json")), bnd);
    RdfParser rdf = new RdfParser();
    rdf.setOutputStyle(OutputStyle.PRETTY);
    rdf.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.ttl")), bnd);
    ttlToXhtml("namingsystem-terminologies", "Terminology Registry", TextFile.fileToString(Utilities.path(page.getFolders().dstDir, "namingsystem-terminologies.ttl")), "resource-instance:NamingSystem", "Terminology Registry", null, wg("vocab"));
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">\r\n");
    b.append(" <tr>");
    b.append("<td><b>Name</b></td>");
    b.append("<td><b>Uri</b></td>");
    b.append("<td><b>OID</b></td>");
    b.append("</tr>\r\n");
    for (BundleEntryComponent entry : bnd.getEntry()) {
        NamingSystem ns = (NamingSystem) entry.getResource();
        String uri = "";
        String oid = "";
        for (NamingSystemUniqueIdComponent id : ns.getUniqueId()) {
            if (id.getType() == NamingSystemIdentifierType.URI)
                uri = id.getValue();
            if (id.getType() == NamingSystemIdentifierType.OID)
                oid = id.getValue();
        }
        String link = "terminologies-systems.html#" + uri;
        if (ns.getUserData("path") != null)
            link = ns.getUserString("path");
        b.append(" <tr>");
        b.append("<td><a href=\"" + link + "\">" + Utilities.escapeXml(ns.getName()) + "</a></td>");
        b.append("<td>" + Utilities.escapeXml(uri) + "</td>");
        b.append("<td>" + Utilities.escapeXml(oid) + "</td>");
        b.append("</tr>\r\n");
    }
    b.append("</table>\r\n");
    String html = TextFile.fileToString(page.getFolders().templateDir + "template-example.html").replace("<%example%>", b.toString()).replace("<%example-usage%>", "");
    html = page.processPageIncludes("namingsystem-terminologies.html", html, "resource-instance:NamingSystem", null, bnd, null, "Example", null, null, page.getDefinitions().getWorkgroups().get("fhir"));
    TextFile.stringToFile(html, page.getFolders().dstDir + "namingsystem-terminologies.html");
    cachePage("namingsystem-terminologies.html", html, "Registered Code Systems", false);
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) NamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) Bundle(org.hl7.fhir.r5.model.Bundle) ArrayList(java.util.ArrayList) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) FileOutputStream(java.io.FileOutputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) HashSet(java.util.HashSet) JsonParser(org.hl7.fhir.r5.formats.JsonParser) RdfParser(org.hl7.fhir.r5.formats.RdfParser)

Example 2 with NamingSystemUniqueIdComponent

use of org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent 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 3 with NamingSystemUniqueIdComponent

use of org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent in project org.hl7.fhir.core by hapifhir.

the class NamingSystemRenderer method render.

public boolean render(XhtmlNode x, NamingSystem ns) throws FHIRFormatError, DefinitionException, IOException {
    x.h3().tx("Summary");
    XhtmlNode tbl = x.table("grid");
    row(tbl, "Defining URL", ns.getUrl());
    if (ns.hasVersion()) {
        row(tbl, "Version", ns.getVersion());
    }
    if (ns.hasName()) {
        row(tbl, "Name", gt(ns.getNameElement()));
    }
    if (ns.hasTitle()) {
        row(tbl, "Title", gt(ns.getTitleElement()));
    }
    row(tbl, "Status", ns.getStatus().toCode());
    if (ns.hasDescription()) {
        addMarkdown(row(tbl, "Definition"), ns.getDescription());
    }
    if (ns.hasPublisher()) {
        row(tbl, "Publisher", gt(ns.getPublisherElement()));
    }
    if (ns.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
        renderCommitteeLink(row(tbl, "Committee"), ns);
    }
    if (CodeSystemUtilities.hasOID(ns)) {
        row(tbl, "OID", CodeSystemUtilities.getOID(ns)).tx("(" + translate("ns.summary", "for OID based terminology systems") + ")");
    }
    if (ns.hasCopyright()) {
        addMarkdown(row(tbl, "Copyright"), ns.getCopyright());
    }
    boolean hasPreferred = false;
    boolean hasPeriod = false;
    boolean hasComment = false;
    for (NamingSystemUniqueIdComponent id : ns.getUniqueId()) {
        hasPreferred = hasPreferred || id.hasPreferred();
        hasPeriod = hasPeriod || id.hasPeriod();
        hasComment = hasComment || id.hasComment();
    }
    x.h3().tx("Identifiers");
    tbl = x.table("grid");
    XhtmlNode tr = tbl.tr();
    tr.td().b().tx(translate("ns.summary", "Type"));
    tr.td().b().tx(translate("ns.summary", "Value"));
    if (hasPreferred) {
        tr.td().b().tx(translate("ns.summary", "Preferred"));
    }
    if (hasPeriod) {
        tr.td().b().tx(translate("ns.summary", "Period"));
    }
    if (hasComment) {
        tr.td().b().tx(translate("ns.summary", "Comment"));
    }
    for (NamingSystemUniqueIdComponent id : ns.getUniqueId()) {
        tr = tbl.tr();
        tr.td().tx(id.getType().getDisplay());
        tr.td().tx(id.getValue());
        if (hasPreferred) {
            tr.td().tx(id.getPreferredElement().primitiveValue());
        }
        if (hasPeriod) {
            tr.td().tx(display(id.getPeriod()));
        }
        if (hasComment) {
            tr.td().tx(id.getComment());
        }
    }
    return false;
}
Also used : NamingSystemUniqueIdComponent(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 4 with NamingSystemUniqueIdComponent

use of org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent in project org.hl7.fhir.core by hapifhir.

the class NamingSystemRenderer method render.

public boolean render(XhtmlNode x, NamingSystem ns) throws FHIRFormatError, DefinitionException, IOException {
    x.h3().tx("Summary");
    XhtmlNode tbl = x.table("grid");
    row(tbl, "Defining URL", ns.getUrl());
    if (ns.hasVersion()) {
        row(tbl, "Version", ns.getVersion());
    }
    if (ns.hasName()) {
        row(tbl, "Name", gt(ns.getNameElement()));
    }
    if (ns.hasTitle()) {
        row(tbl, "Title", gt(ns.getTitleElement()));
    }
    row(tbl, "Status", ns.getStatus().toCode());
    if (ns.hasDescription()) {
        addMarkdown(row(tbl, "Definition"), ns.getDescription());
    }
    if (ns.hasPublisher()) {
        row(tbl, "Publisher", gt(ns.getPublisherElement()));
    }
    if (ns.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
        renderCommitteeLink(row(tbl, "Committee"), ns);
    }
    if (CodeSystemUtilities.hasOID(ns)) {
        row(tbl, "OID", CodeSystemUtilities.getOID(ns)).tx("(" + translate("ns.summary", "for OID based terminology systems") + ")");
    }
    if (ns.hasCopyright()) {
        addMarkdown(row(tbl, "Copyright"), ns.getCopyright());
    }
    boolean hasPreferred = false;
    boolean hasPeriod = false;
    boolean hasComment = false;
    for (NamingSystemUniqueIdComponent id : ns.getUniqueId()) {
        hasPreferred = hasPreferred || id.hasPreferred();
        hasPeriod = hasPeriod || id.hasPeriod();
        hasComment = hasComment || id.hasComment();
    }
    x.h3().tx("Identifiers");
    tbl = x.table("grid");
    XhtmlNode tr = tbl.tr();
    tr.td().b().tx(translate("ns.summary", "Type"));
    tr.td().b().tx(translate("ns.summary", "Value"));
    if (hasPreferred) {
        tr.td().b().tx(translate("ns.summary", "Preferred"));
    }
    if (hasPeriod) {
        tr.td().b().tx(translate("ns.summary", "Period"));
    }
    if (hasComment) {
        tr.td().b().tx(translate("ns.summary", "Comment"));
    }
    for (NamingSystemUniqueIdComponent id : ns.getUniqueId()) {
        tr = tbl.tr();
        tr.td().tx(id.getType().getDisplay());
        tr.td().tx(id.getValue());
        if (hasPreferred) {
            tr.td().tx(id.getPreferredElement().primitiveValue());
        }
        if (hasPeriod) {
            tr.td().tx(display(id.getPeriod()));
        }
        if (hasComment) {
            tr.td().tx(id.getComment());
        }
    }
    return false;
}
Also used : NamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 5 with NamingSystemUniqueIdComponent

use of org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent in project org.hl7.fhir.core by hapifhir.

the class NamingSystem method setProperty.

@Override
public Base setProperty(String name, Base value) throws FHIRException {
    if (name.equals("name")) {
        // StringType
        this.name = castToString(value);
    } else if (name.equals("status")) {
        value = new PublicationStatusEnumFactory().fromType(castToCode(value));
        // Enumeration<PublicationStatus>
        this.status = (Enumeration) value;
    } else if (name.equals("kind")) {
        value = new NamingSystemTypeEnumFactory().fromType(castToCode(value));
        // Enumeration<NamingSystemType>
        this.kind = (Enumeration) value;
    } else if (name.equals("date")) {
        // DateTimeType
        this.date = castToDateTime(value);
    } else if (name.equals("publisher")) {
        // StringType
        this.publisher = castToString(value);
    } else if (name.equals("contact")) {
        this.getContact().add(castToContactDetail(value));
    } else if (name.equals("responsible")) {
        // StringType
        this.responsible = castToString(value);
    } else if (name.equals("type")) {
        // CodeableConcept
        this.type = castToCodeableConcept(value);
    } else if (name.equals("description")) {
        // MarkdownType
        this.description = castToMarkdown(value);
    } else if (name.equals("useContext")) {
        this.getUseContext().add(castToUsageContext(value));
    } else if (name.equals("jurisdiction")) {
        this.getJurisdiction().add(castToCodeableConcept(value));
    } else if (name.equals("usage")) {
        // StringType
        this.usage = castToString(value);
    } else if (name.equals("uniqueId")) {
        this.getUniqueId().add((NamingSystemUniqueIdComponent) value);
    } else if (name.equals("replacedBy")) {
        // Reference
        this.replacedBy = castToReference(value);
    } else
        return super.setProperty(name, value);
    return value;
}
Also used : PublicationStatusEnumFactory(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)

Aggregations

NamingSystemUniqueIdComponent (org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent)3 ArrayList (java.util.ArrayList)2 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)2 NamingSystem (org.hl7.fhir.r5.model.NamingSystem)2 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 FileOutputStream (java.io.FileOutputStream)1 HashSet (java.util.HashSet)1 Compartment (org.hl7.fhir.definitions.model.Compartment)1 NamespacePair (org.hl7.fhir.definitions.model.Definitions.NamespacePair)1 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)1 PublicationStatusEnumFactory (org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)1 NamingSystemUniqueIdComponent (org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent)1 JsonParser (org.hl7.fhir.r5.formats.JsonParser)1 RdfParser (org.hl7.fhir.r5.formats.RdfParser)1 XmlParser (org.hl7.fhir.r5.formats.XmlParser)1 Bundle (org.hl7.fhir.r5.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)1 ConceptMap (org.hl7.fhir.r5.model.ConceptMap)1 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)1