Search in sources :

Example 1 with BindingSpecification

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

the class Publisher method loadValueSets1.

private void loadValueSets1() throws Exception {
    page.log(" ...vocab #1", LogMessageType.Process);
    generateCodeSystemsPart1();
    generateValueSetsPart1();
    for (BindingSpecification cd : page.getDefinitions().getUnresolvedBindings()) {
        String ref = cd.getReference();
        if (ref.startsWith("http://hl7.org/fhir")) {
            // we expect to be able to resolve this
            ValueSet vs = page.getDefinitions().getValuesets().get(ref);
            if (vs == null)
                vs = page.getDefinitions().getExtraValuesets().get(ref);
            if (vs == null)
                vs = page.getWorkerContext().fetchResource(ValueSet.class, ref);
            if (vs == null) {
                if (page.getDefinitions().getBoundValueSets().containsKey(ref))
                    throw new Exception("Unable to resolve the value set reference " + ref + " but found it in load list");
                throw new Exception("Unable to resolve the value set reference " + ref);
            }
            cd.setValueSet(vs);
        } else {
            ValueSet vs = page.getWorkerContext().fetchResource(ValueSet.class, ref);
            if (vs != null)
                cd.setValueSet(vs);
            else if (!ref.startsWith("http://loinc.org/vs/LL"))
                System.out.println("Unresolved value set reference: " + ref);
        }
    }
    for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) {
        for (BindingSpecification cd : ig.getUnresolvedBindings()) {
            String ref = cd.getReference();
            if (ref.contains("|"))
                ref = ref.substring(0, ref.indexOf("|"));
            ValueSet vs = page.getDefinitions().getValuesets().get(ref);
            if (vs == null)
                vs = ig.getValueSet(ref);
            if (vs == null)
                vs = page.getWorkerContext().fetchResource(ValueSet.class, ref);
            if (vs == null)
                throw new Exception("unable to resolve value set " + ref);
            cd.setValueSet(vs);
        }
    }
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ValueSet(org.hl7.fhir.r5.model.ValueSet) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with BindingSpecification

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

the class PageProcessor method genCodeSystemsTable.

private String genCodeSystemsTable() throws Exception {
    StringBuilder s = new StringBuilder();
    s.append("<table class=\"codes\">\r\n");
    List<String> names = new ArrayList<String>();
    names.addAll(definitions.getCodeSystems().keys());
    // for (String n : definitions.getBindings().keySet()) {
    // if ((definitions.getBindingByName(n).getBinding() == Binding.CodeList && !definitions.getBindingByName(n).getVSSources().contains("")) ||
    // (definitions.getBindingByName(n).getBinding() == Binding.Special))
    // names.add(definitions.getBindingByName(n).getReference().substring(1));
    // }
    // 
    // //  not this one      Logical Interactions (RESTful framework)  http://hl7.org/fhir/rest-operations 2.16.840.1.113883.6.308
    // s.append(" <tr><td><a href=\""+cd.getReference().substring(1)+".html\">http://hl7.org/fhir/"+cd.getReference().substring(1)+"</a></td><td>"+Utilities.escapeXml(cd.getDefinition())+"</td></tr>\r\n");
    // 
    Collections.sort(names);
    for (String n : names) {
        if (n.startsWith("http://hl7.org") && !n.startsWith("http://terminology.hl7.org/CodeSystem/v2") && !n.startsWith("http://terminology.hl7.org/CodeSystem/v3")) {
            // BindingSpecification cd = definitions.getBindingByReference("#"+n);
            CodeSystem ae = definitions.getCodeSystems().get(n);
            if (ae == null)
                s.append(" <tr><td><a href=\"" + "??" + ".html\">").append(n).append("</a></td><td>").append("??").append("</td></tr>\r\n");
            else {
                s.append(" <tr><td><a href=\"").append(ae.getUserData("path")).append("\">").append(n).append("</a></td><td>").append(ae.getDescription()).append("</td></tr>\r\n");
            }
        }
    }
    s.append("</table>\r\n");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 3 with BindingSpecification

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

the class BookMaker method addContent.

private void addContent(XhtmlNode body) throws Exception {
    List<String> list = new ArrayList<String>();
    loadResources(list, page.getDefinitions().getResources().keySet());
    XhtmlNode e = body.getElement("contents");
    XhtmlNode div = body.addTag(body.getChildNodes().indexOf(e), "div");
    body.getChildNodes().remove(e);
    List<String> links = new ArrayList<String>();
    LevelCounter lvl = new LevelCounter();
    lvl.l1 = 0;
    for (Navigation.Category s : page.getNavigation().getCategories()) {
        lvl.l1++;
        // div.addTag("div").setAttribute("class", "page-break");
        XhtmlNode divS = div.addTag("div");
        divS.attribute("class", "section");
        XhtmlNode h1 = divS.addTag("h1");
        h1.addText(Integer.toString(lvl.l1) + ": " + s.getName());
        addPageContent(lvl, divS, s.getLink(), s.getName());
        links.add(s.getLink());
        lvl.l2 = 0;
        for (Navigation.Entry n : s.getEntries()) {
            lvl.l2++;
            lvl.l3 = 0;
            if (n.getLink() != null) {
                if (n.getLink().equals("[codes]")) {
                    lvl.l2--;
                    List<String> names = new ArrayList<String>();
                    throw new Error("fix this");
                // for (BindingSpecification bs : page.getDefinitions().getBindings().values()) {
                // if (bs.getBinding() == Binding.CodeList)
                // names.add(bs.getReference());
                // }
                // Collections.sort(names);
                // for (String l : names) {
                // addPageContent(lvl, divS, l.substring(1), page.getDefinitions().getBindingByReference(l).getName());
                // //              links.add(l.substring(1));
                // }
                } else {
                    addPageContent(lvl, divS, n.getLink(), n.getName());
                    links.add(n.getLink());
                }
            }
            for (Navigation.Entry g : n.getEntries()) {
                if (g.getLink() != null) {
                    addPageContent(lvl, divS, g.getLink(), g.getName());
                    links.add(g.getLink());
                }
            }
        }
        if (s.getEntries().size() == 0 && s.getLink().equals("resourcelist")) {
            for (String rn : list) {
                if (!links.contains(rn.toLowerCase())) {
                    lvl.l2++;
                    lvl.l3 = 0;
                    ResourceDefn r = page.getDefinitions().getResourceByName(rn);
                    addPageContent(lvl, divS, rn.toLowerCase(), r.getName());
                }
            }
        }
        if (s.getLink().equals("page") && s.getName().equals("Examples")) {
            for (String rn : list) {
                lvl.l2++;
                lvl.l3 = 0;
                ResourceDefn r = page.getDefinitions().getResourceByName(rn);
                addPageContent(lvl, divS, rn.toLowerCase() + "Ex", r.getName());
            }
        }
        if (s.getLink().equals("page") && s.getName().equals("Detailed Descriptions")) {
            for (String rn : list) {
                lvl.l2++;
                lvl.l3 = 0;
                ResourceDefn r = page.getDefinitions().getResourceByName(rn);
                addPageContent(lvl, divS, rn.toLowerCase() + "Defn", r.getName());
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 4 with BindingSpecification

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

the class ValueSetGenerator method loadOperationOutcomeValueSet.

public void loadOperationOutcomeValueSet(BindingSpecification cd) throws Exception {
    ValueSet vs = new ValueSet();
    cd.setValueSet(vs);
    cd.setBindingMethod(BindingMethod.ValueSet);
    vs.setId("operation-outcome");
    vs.setUrl("http://hl7.org/fhir/ValueSet/" + vs.getId());
    vs.setName("OperationOutcomeCodes");
    vs.setTitle("Operation Outcome Codes");
    vs.setPublisher("HL7 (FHIR Project)");
    vs.setVersion(version);
    vs.setUserData("filename", "valueset-" + vs.getId());
    if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
        vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
    } else {
        String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
        if (!ec.equals("fhir"))
            System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 11: is " + ec + ", want to set to " + "fhir");
    }
    vs.setUserData("path", "valueset-" + vs.getId() + ".html");
    ContactDetail c = vs.addContact();
    c.addTelecom().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
    c.addTelecom().setSystem(ContactPointSystem.EMAIL).setValue("fhir@lists.hl7.org");
    vs.setDescription("Operation Outcome codes used by FHIR test servers (see Implementation file translations.xml)");
    vs.setStatus(PublicationStatus.DRAFT);
    if (!vs.hasCompose())
        vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().addInclude().setSystem("http://terminology.hl7.org/CodeSystem/operation-outcome");
    CodeSystem cs = new CodeSystem();
    cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.ISA);
    Set<String> codes = translator.listTranslations("ecode");
    for (String s : sorted(codes)) {
        Map<String, String> langs = translator.translations(s);
        ConceptDefinitionComponent cv = cs.addConcept();
        cv.setCode(s);
        cv.setDisplay(langs.get("en"));
        for (String lang : langs.keySet()) {
            if (!lang.equals("en")) {
                String value = langs.get(lang);
                ConceptDefinitionDesignationComponent dc = cv.addDesignation();
                dc.setLanguage(lang);
                dc.setValue(value);
                dc.getUse().setSystem("http://terminology.hl7.org/CodeSystem/designation-usage").setCode("display");
            }
        }
    }
    CodeSystemConvertor.populate(cs, vs);
    cs.setUrl("http://terminology.hl7.org/CodeSystem/operation-outcome");
    cs.setVersion(version);
    cs.setCaseSensitive(true);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    definitions.getCodeSystems().see(cs, packageInfo);
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) CodeType(org.hl7.fhir.r5.model.CodeType) ValueSet(org.hl7.fhir.r5.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 5 with BindingSpecification

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

the class BindingsParser method parse.

public List<BindingSpecification> parse() throws Exception {
    List<BindingSpecification> results = new ArrayList<BindingSpecification>();
    // BindingSpecification n = new BindingSpecification();
    // n.setName("*unbound*");
    // n.setBinding(BindingSpecification.Binding.Unbound);
    // results.add(n);
    xls = new XLSXmlParser(file, filename);
    new XLSXmlNormaliser(filename, exceptionIfExcelNotNormalised).go();
    Sheet sheet = xls.getSheets().get("Bindings");
    for (int row = 0; row < sheet.rows.size(); row++) {
        processLine(results, sheet, row);
    }
    return results;
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ArrayList(java.util.ArrayList) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) XLSXmlNormaliser(org.hl7.fhir.utilities.xls.XLSXmlNormaliser) Sheet(org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet)

Aggregations

BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)20 ValueSet (org.hl7.fhir.r5.model.ValueSet)13 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)10 ArrayList (java.util.ArrayList)8 TypeRef (org.hl7.fhir.definitions.model.TypeRef)6 FHIRException (org.hl7.fhir.exceptions.FHIRException)6 IOException (java.io.IOException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 CodeType (org.hl7.fhir.r5.model.CodeType)4 FileNotFoundException (java.io.FileNotFoundException)3 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)3 CSFile (org.hl7.fhir.utilities.CSFile)3 JsonObject (com.google.gson.JsonObject)2 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 TransformerException (javax.xml.transform.TransformerException)2 DefinedCode (org.hl7.fhir.definitions.model.DefinedCode)2 Invariant (org.hl7.fhir.definitions.model.Invariant)2 ProfiledType (org.hl7.fhir.definitions.model.ProfiledType)2 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)2