Search in sources :

Example 6 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class OldSpreadsheetParser method checkW5.

private String checkW5(String value, String path) throws Exception {
    if (Utilities.noString(value))
        return null;
    if (!definitions.getW5s().containsKey(value)) {
        if (!value.contains(".")) {
            throw new Exception("Unknown w5 value " + value + " at " + path);
        } else {
            String[] vs = value.split("\\.");
            if (vs.length != 2)
                throw new Exception("improper w5 value " + value + " at " + path);
            if (!definitions.getW5s().containsKey(vs[0]))
                throw new Exception("Unknown w5 value " + value + " at " + path);
            W5Entry w5 = definitions.getW5s().get(vs[0]);
            if (!w5.getSubClasses().contains(vs[1]))
                throw new Exception("Unknown w5 value " + value + " at " + path);
        }
    }
    return value;
}
Also used : W5Entry(org.hl7.fhir.definitions.model.W5Entry) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 7 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class OldSpreadsheetParser method readSearchParams.

private void readSearchParams(ResourceDefn root2, Sheet sheet, boolean forProfile) throws Exception {
    if (sheet != null) {
        for (int row = 0; row < sheet.rows.size(); row++) {
            if (!sheet.hasColumn(row, "Name"))
                throw new Exception("Search Param has no name " + getLocation(row));
            String n = sheet.getColumn(row, "Name");
            if (!n.startsWith("!")) {
                if (!sheet.hasColumn(row, "Type"))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + " has no type " + getLocation(row));
                if (n.endsWith("-before") || n.endsWith("-after"))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + " includes relative time " + getLocation(row));
                if (root2.getSearchParams().containsKey(n))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + ": duplicate name " + getLocation(row));
                String d = sheet.getColumn(row, "Description");
                SearchType t = readSearchType(sheet.getColumn(row, "Type"), row);
                SearchParameter.XPathUsageType pu = readSearchXPathUsage(sheet.getColumn(row, "Path Usage"), row);
                if (Utilities.noString(sheet.getColumn(row, "Path")) && !root2.getName().equals("Resource") && !root2.getName().equals("DomainResource"))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + " has no path at " + getLocation(row));
                SearchParameterDefn sp = null;
                if (t == SearchType.composite) {
                    List<CompositeDefinition> pn = new ArrayList<CompositeDefinition>();
                    if (Utilities.noString(d))
                        throw new Exception("Search Param " + root2.getName() + "/" + n + " has no description " + getLocation(row));
                    String[] pl = sheet.getColumn(row, "Path").split("\\&");
                    String[] pe = sheet.getColumn(row, "Expression").split("\\;");
                    if (pe.length != pl.length + 1)
                        throw new Exception("Composite Search Param " + root2.getName() + "/" + n + " needs expressions " + getLocation(row));
                    int i = 0;
                    for (String pi : pl) {
                        String p = pi.trim();
                        i++;
                        String e = pe[i].trim();
                        if (!root2.getSearchParams().containsKey(p)) {
                            boolean found = false;
                            if (p.endsWith("[x]"))
                                for (String pan : root2.getSearchParams().keySet()) {
                                    if (pan.startsWith(p.substring(0, p.length() - 3)))
                                        found = true;
                                }
                            if (!found)
                                throw new Exception("Composite Search Param " + root2.getName() + "/" + n + "  refers to an unknown component " + p + " at " + getLocation(row));
                        }
                        pn.add(new CompositeDefinition(p, e));
                    }
                    StandardsStatus ss = root2.getStatus();
                    if (!Utilities.noString(sheet.getColumn(row, "Standards-Status")))
                        ss = StandardsStatus.fromCode(sheet.getColumn(row, "Standards-Status"));
                    sp = new SearchParameterDefn(n, d, t, pu, ss);
                    sp.setExpression(pe[0].trim());
                    sp.getComposites().addAll(pn);
                } else {
                    List<String> pn = new ArrayList<String>();
                    String xp = sheet.getColumn(row, "XPath");
                    String[] pl = sheet.getColumn(row, "Path").split("\\|");
                    boolean hierarchy = false;
                    for (String pi : pl) {
                        String p = pi.trim();
                        ElementDefn e = null;
                        if (!Utilities.noString(p) && !p.startsWith("!") && !p.startsWith("Extension{") && definitions != null) {
                            e = root2.getRoot().getElementForPath(trimIndexes(p), definitions, "search param", true, true);
                        }
                        if (e != null && e.hasHierarchy() && e.getHierarchy())
                            hierarchy = true;
                        if (Utilities.noString(d) && e != null)
                            d = e.getShortDefn();
                        if (p.startsWith("Extension(")) {
                            String url = extractExtensionUrl(p);
                            StructureDefinition ex = context.fetchResource(StructureDefinition.class, url);
                            if (ex == null)
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " refers to unknown extension '" + url + "' " + getLocation(row));
                            if (Utilities.noString(d))
                                d = ex.getDescription();
                            pn.add(p);
                        }
                        if (d == null)
                            throw new Exception("Search Param " + root2.getName() + "/" + n + " has no description " + getLocation(row));
                        if (e != null)
                            pn.add(p);
                        if (t == SearchType.reference) {
                            if (e == null && !forProfile && !sheet.hasColumn(row, "Target Types"))
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " of type reference has wrong path '" + p + "' at " + getLocation(row));
                            if (!forProfile && e != null && (!e.hasType("Reference")) && (!e.hasType("canonical")) && (!e.hasType("Resource")))
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is reference, but the element type is " + e.typeCode());
                        } else {
                            if (e != null && e.hasOnlyType("Reference"))
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + t.toString() + ", but the element type is " + e.typeCode());
                            if (t == SearchType.uri) {
                                if (e != null && !(e.typeCode().equals("uri") || e.typeCode().equals("url") || e.typeCode().equals("oid") || e.typeCode().startsWith("canonical(")))
                                    throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + t.toString() + ", but the element type is " + e.typeCode());
                            } else {
                                if (e != null && e.typeCode().equals("uri"))
                                    throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + t.toString() + ", but the element type is " + e.typeCode());
                            }
                        }
                    }
                    if (!forProfile && t == SearchType.reference && pn.size() == 0 && !sheet.hasColumn(row, "Target Types"))
                        throw new Exception("Search Param " + root2.getName() + "/" + n + " of type reference has no path(s) " + getLocation(row));
                    StandardsStatus ss = root2.getStatus();
                    if (!Utilities.noString(sheet.getColumn(row, "Standards-Status")))
                        ss = StandardsStatus.fromCode(sheet.getColumn(row, "Standards-Status"));
                    sp = new SearchParameterDefn(n, d, t, pu, ss);
                    sp.getPaths().addAll(pn);
                    if (!Utilities.noString(xp))
                        sp.setXPath(xp);
                    if (!Utilities.noString(sheet.getColumn(row, "Expression")))
                        sp.setExpression(sheet.getColumn(row, "Expression"));
                    if (!Utilities.noString(sheet.getColumn(row, "Target Types"))) {
                        sp.setManualTypes(sheet.getColumn(row, "Target Types").split("\\,"));
                    }
                    sp.setHierarchy(hierarchy);
                    CommonSearchParameter csp = definitions.getCommonSearchParameters().get(root2.getName() + "::" + n);
                    if (csp != null)
                        for (String s : csp.getResources()) {
                            if (!root2.getName().equals(s))
                                sp.getOtherResources().add(s);
                        }
                }
                root2.getSearchParams().put(n, sp);
            }
        }
    }
}
Also used : SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) FHIRException(org.hl7.fhir.exceptions.FHIRException) CompositeDefinition(org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchType(org.hl7.fhir.definitions.model.SearchParameterDefn.SearchType) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus)

Example 8 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class OldSpreadsheetParser method readSearchParams.

/* for profiles that have a "search" tab not tied to a structure */
private void readSearchParams(Profile pack, Sheet sheet, String prefix) throws Exception {
    for (int row = 0; row < sheet.rows.size(); row++) {
        if (!sheet.hasColumn(row, "Name"))
            throw new Exception("Search Param has no name " + getLocation(row));
        String n = sheet.getColumn(row, "Name");
        if (!n.startsWith("!")) {
            SearchParameter sp = new SearchParameter();
            if (!sheet.hasColumn(row, "Type"))
                throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has no type " + getLocation(row));
            if (n.endsWith("-before") || n.endsWith("-after"))
                throw new Exception("Search Param " + pack.getTitle() + "/" + n + " includes relative time " + getLocation(row));
            // if (!n.toLowerCase().equals(n))
            // throw new Exception("Search Param "+pack.getTitle()+"/"+n+" must be all lowercase "+ getLocation(row));
            sp.setVersion(version.toCode());
            sp.setName(n);
            sp.setCode(n);
            if (pack.getProfiles().size() > 0 && pack.getProfiles().get(0).getResource() != null) {
                sp.setStatus(pack.getProfiles().get(0).getResource().getStatus());
                sp.setExperimental(pack.getProfiles().get(0).getResource().getExperimental());
            } else {
                // we just guess
                sp.setStatus(PublicationStatus.DRAFT);
                sp.setExperimental(true);
            }
            String d = sheet.getColumn(row, "Description");
            sp.setType(SearchParamType.fromCode(sheet.getColumn(row, "Type")));
            List<String> pn = new ArrayList<String>();
            String path = sheet.getColumn(row, "Path");
            if (Utilities.noString(path))
                throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has no path");
            if (!path.contains(".") && !path.startsWith("#"))
                throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has an invalid path: " + path);
            ResourceDefn root2 = null;
            if (!path.startsWith("#")) {
                path = path.substring(0, path.indexOf('.'));
                if (!pkp.isResource(path))
                    throw new Exception("Ilegal Search Parameter path " + sheet.getColumn(row, "Path"));
                sp.addBase(path);
                sp.setId(pack.getId() + "-" + path + "-" + sp.getName());
                if (definitions != null) {
                    // igtodo (and below)
                    root2 = definitions.getResourceByName(path);
                    if (root2 == null)
                        throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has an invalid path (resource not found)");
                    if (!pkp.isResource(root2.getName()))
                        throw new Exception("Ilegal Search Parameter path " + sheet.getColumn(row, "Path"));
                    sp.getBase().clear();
                    sp.addBase(root2.getName());
                    sp.setId(pack.getId() + "-" + (root2 == null ? "all" : root2.getName()) + "-" + sp.getName());
                }
            }
            if (!Utilities.noString(sheet.getColumn(row, "Target Types")))
                throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has manually specified targets (not allowed)");
            if (root2 != null && root2.getSearchParams().containsKey(n))
                throw new Exception("Search Param " + root2.getName() + "/" + n + ": duplicate name " + getLocation(row));
            if (sp.getType() == SearchParamType.COMPOSITE) {
                throw new Exception("not supported");
            } else {
                String[] pl = sheet.getColumn(row, "Path").split("\\|");
                String xp = sheet.getColumn(row, "XPath");
                for (String pi : pl) {
                    String p = pi.trim();
                    ElementDefn e = null;
                    if (Utilities.noString(p))
                        throw new Exception("Search Param " + root2.getName() + "/" + n + ": empty path " + getLocation(row));
                    if (p.startsWith("#")) {
                        // root less extension search parameter
                        StructureDefinition ex = pack.getExtension(prefix + p.substring(1));
                        if (ex == null)
                            throw new Exception("Search Param " + pack.getTitle() + "/" + n + " refers to unknown extension '" + p + "' " + getLocation(row));
                        e = definitions.getElementDefn("Extension");
                        if (ex.getContext().size() != 1 || ex.getContext().get(0).getType() != ExtensionContextType.ELEMENT)
                            throw new Exception("Search Param " + pack.getTitle() + "/" + n + " refers to an extension with multiple contexts, not not an element context - not supported '" + p + "' " + getLocation(row));
                        path = ex.getContext().get(0).getExpression();
                        if (Utilities.noString(path))
                            throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has no path");
                        if (path.contains("."))
                            path = path.substring(0, path.indexOf('.'));
                        sp.setId(pack.getId() + "-" + path + "-" + sp.getName());
                        root2 = definitions.getResourceByName(path);
                        if (root2 == null)
                            throw new Exception("Search Param " + pack.getTitle() + "/" + n + " has an invalid path (resource not found)");
                        if (root2 != null && root2.getSearchParams().containsKey(n))
                            throw new Exception("Search Param " + root2.getName() + "/" + n + ": duplicate name " + getLocation(row));
                        sp.setId(pack.getId() + "-" + path + "-" + sp.getName());
                        pn.add(ex.getContext().get(0).getExpression() + ".extension{" + ex.getUrl() + "}");
                    } else if (p.contains(".extension{")) {
                        String url = extractExtensionUrl(p);
                        // not created yet?
                        StructureDefinition ex = context.fetchResource(StructureDefinition.class, url);
                        if (ex == null)
                            ex = context.getExtensionStructure(null, url);
                        if (ex == null)
                            throw new Exception("Search Param " + pack.getTitle() + "/" + n + " refers to unknown extension '" + url + "' " + getLocation(row));
                        if (Utilities.noString(d))
                            d = ex.getDescription();
                        if (definitions != null)
                            e = definitions.getElementDefn("Extension");
                        pn.add(p);
                    } else if (!p.startsWith("!") && !p.startsWith("Extension{") && root2 != null) {
                        e = root2.getRoot().getElementForPath(p, definitions, "search param", true, true);
                    }
                    if (e == null && Utilities.noString(d))
                        throw new Exception("unable to resolve sarch param " + p);
                    if (e == null)
                        sp.setExpression(p);
                    if (Utilities.noString(d) && e != null)
                        d = e.getShortDefn();
                    if (d == null)
                        throw new Exception("Search Param " + root2.getName() + "/" + n + " has no description " + getLocation(row));
                    if (e != null)
                        pn.add(p);
                    if (sp.getType() == SearchParamType.REFERENCE) {
                    // no check?
                    } else if (e != null && e.typeCode().startsWith("Reference("))
                        throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + sp.getType().toCode() + ", but the element type is " + e.typeCode());
                    sp.setDescription(d);
                }
                sp.setXpath(Utilities.noString(xp) ? new XPathQueryGenerator(definitions, log, null).generateXpath(pn, null) : xp);
                sp.setXpathUsage(readSearchXPathUsage(sheet.getColumn(row, "Path Usage"), row));
            }
            sp.setUrl("http://hl7.org/fhir/SearchParameter/" + sp.getId());
            if (definitions != null)
                definitions.addNs(sp.getUrl(), "Search Parameter " + sp.getName(), pack.getId() + ".html#search");
            if (context.getSearchParameter(sp.getUrl()) != null)
                throw new Exception("Duplicated Search Parameter " + sp.getUrl());
            context.cacheResource(sp);
            pack.getSearchParameters().add(sp);
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) XPathQueryGenerator(org.hl7.fhir.definitions.generators.specification.XPathQueryGenerator) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 9 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class Regenerator method generateCP.

private void generateCP(String root, ResourceDefn r, Profile p) throws IOException {
    ImplementationGuide ig = new ImplementationGuide();
    ig.setId(r.getName() + "-" + p.getCategory());
    ig.setTitle(p.getTitle());
    ig.setStatus(PublicationStatus.ACTIVE);
    ig.setDate(new Date(r.getTimestamp()));
    for (String s : p.getMetadata().keySet()) {
        List<String> vl = p.getMetadata().get(s);
        for (String v : vl) {
            if (!Utilities.noString(v)) {
                switch(s) {
                    // case "id": ig.setId(v); break;
                    case "name":
                        ig.setName(v);
                        break;
                    case "author.name":
                        ig.setPublisher(v);
                        break;
                    case "code":
                        ig.addExtension(BuildExtensions.EXT_CODE, new CodeType(v));
                        break;
                    case "fmm":
                        ig.addExtension(ToolingExtensions.EXT_FMM_LEVEL, new CodeType(v));
                        break;
                    case "description":
                        ig.setDescription(v);
                        break;
                    case "status":
                        ig.setStatus(PublicationStatus.fromCode(v));
                        break;
                    case "publication.status":
                        break;
                    case "version":
                        ig.setVersion(v);
                        break;
                    case "display":
                        ig.setTitle(v);
                        break;
                    case "workgroup":
                        ig.addExtension(ToolingExtensions.EXT_WORKGROUP, new CodeType(v));
                        break;
                    case "date":
                        ig.getDateElement().setValueAsString(v);
                        break;
                    case "Experimental":
                        ig.setExperimental(Utilities.existsInList(v.toLowerCase(), "y", "yes", "1", "true"));
                        break;
                    default:
                        if (s.startsWith("fmm-") || Utilities.existsInList(s, "extension.uri", "author.reference", "published.structure", "notes", "introduction") || s.startsWith("!")) {
                        // ignore these
                        } else if (s.startsWith("summary-")) {
                            String n = s.substring(8);
                            for (ConstraintStructure cs : p.getProfiles()) {
                                if (n.equals(cs.getTitle()) || n.equals(cs.getId())) {
                                    cs.setSummary(v);
                                }
                            }
                        } else {
                            System.out.println("Unknown metadata item: " + s + "=" + v);
                        }
                }
            }
        }
    }
    if (!Utilities.noString(p.getIntroduction())) {
        ig.addExtension(BuildExtensions.EXT_INTRODUCTION, new StringType(p.getIntroduction()));
    }
    if (!Utilities.noString(p.getNotes())) {
        ig.addExtension(BuildExtensions.EXT_NOTES, new StringType(p.getNotes()));
    }
    for (ConstraintStructure cs : p.getProfiles()) {
        CanonicalResource cr = generateProfile(root, r, p, cs);
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
    }
    for (StructureDefinition cs : p.getExtensions()) {
        CanonicalResource cr = generateExtension(root, r, p, cs.copy());
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
    }
    for (SearchParameter cs : p.getSearchParameters()) {
        CanonicalResource cr = generateSearchParameter(root, r, p, cs);
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
    }
    for (Example cs : p.getExamples()) {
        ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
        generateExample(root, r, p, cs, res);
    }
    File fn = new File(Utilities.path(root, ig.fhirType().toLowerCase() + "-" + ig.getId() + ".gen.xml"));
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), ig);
    fn.setLastModified(r.getTimestamp());
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) StringType(org.hl7.fhir.r5.model.StringType) Date(java.util.Date) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) FileOutputStream(java.io.FileOutputStream) CodeType(org.hl7.fhir.r5.model.CodeType) ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) File(java.io.File)

Example 10 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class TerminologyNotesGenerator method gen.

private void gen(String prefix, Map<BindingSpecification, List<CDUsage>> txusages2) throws Exception {
    List<BindingSpecification> cds = new ArrayList<BindingSpecification>();
    cds.addAll(txusages.keySet());
    if (cds.size() == 0)
        return;
    Collections.sort(cds, new MyCompare());
    if (noHeader)
        write("<p>\r\n<b>Terminology Bindings</b>\r\n</p>\r\n");
    else
        write("<h3>\r\nTerminology Bindings\r\n</h3>\r\n");
    // 1. new form
    write("<table class=\"grid\">\r\n");
    write(" <tr><th>Path</th><th>Definition</th><th>Type</th><th>Reference</th></tr>\r\n");
    for (BindingSpecification cd : cds) {
        String path;
        List<CDUsage> list = txusages.get(cd);
        for (int i = 2; i < list.size(); i++) {
            if (!matchesTypes(list.get(i).element.typeCodeNoParams(), list.get(1).element.typeCodeNoParams()))
                throw new Exception("Mixed types on one concept domain in one type - not yet supported by the build process for binding " + cd.getName() + " (" + list.get(i).element.typeCode() + " vs " + list.get(1).element.typeCode() + ")");
        }
        String name = cd.getValueSet() != null ? cd.getValueSet().present() : cd.getName();
        write(" <tr><td valign=\"top\" title=\"" + name + "\">");
        boolean first = true;
        for (int i = 1; i < list.size(); i++) {
            if (!first)
                write("<br/>");
            first = false;
            write(list.get(i).path);
        }
        write(" </td>");
        write("<td valign=\"top\">" + Utilities.escapeXml(cd.getDefinition()) + "</td>");
        if (cd.getBinding() == BindingMethod.Unbound)
            write("<td>Unknown</td><td valign=\"top\">No details provided yet</td>");
        else {
            if (cd.hasMax()) {
                ValueSet vs = cd.getMaxValueSet();
                if (vs == null) {
                    write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>, but limited to <a href=\"" + cd.getMaxReference() + "\">" + cd.getMaxReference() + "</a></td>");
                } else {
                    String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                    write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>, but limited to <a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + vs.getName() + "</a></td>");
                }
            } else
                write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a></td>");
            write("<td valign=\"top\">");
            if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
                if (name.equals("MessageEvent"))
                    write("<a href=\"" + prefix + "valueset-message-events.html\">Message Events</a>");
                else if (name.equals("ResourceType"))
                    write("<a href=\"" + prefix + "valueset-resource-types.html\">Resource Types</a>");
                else if (name.equals("DataType"))
                    write("<a href=\"" + prefix + "valueset-data-types.html\">Data Types</a>");
                else if (name.equals("FHIRDefinedType"))
                    write("<a href=\"" + prefix + "valueset-defined-types.html\">Defined Types</a>");
                else if (name.equals("FHIRAllTypes"))
                    write("<a href=\"" + prefix + "valueset-all-types.html\">All Types</a>");
                else
                    throw new Exception("Unknown special type " + name);
            } else if (cd.getValueSet() != null) {
                ValueSet vs = cd.getValueSet();
                String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                if (pp == null)
                    throw new Exception("unknown path on " + cd.getReference());
                write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + vs.getName() + "</a><!-- b -->");
            } else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
                if (Utilities.noString(cd.getReference()))
                    write("??");
                else if (cd.getReference().startsWith("valueset-"))
                    write("<a href=\"" + prefix + cd.getReference() + ".html\">http://hl7.org/fhir/ValueSet/" + cd.getReference().substring(9) + "</a><!-- a -->");
                else if (cd.getReference().startsWith("http://hl7.org/fhir")) {
                    if (cd.getReference().startsWith("http://terminology.hl7.org/ValueSet/v3-")) {
                        ValueSet vs = page.getValueSets().get(cd.getReference());
                        String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                        if (pp == null)
                            throw new Exception("unknown path on " + cd.getReference());
                        write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getReference() + "</a><!-- b -->");
                    } else if (cd.getReference().startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
                        ValueSet vs = page.getValueSets().get(cd.getReference());
                        String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                        write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getReference() + "</a><!-- c -->");
                    } else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/")) {
                        String ref = getBindingLink(cd);
                        write("<a href=\"" + prefix + ref + "\">" + cd.getReference() + "</a><!-- d -->");
                    // BindingSpecification bs1 = page.getDefinitions().getBindingByURL(cd.getReference());
                    // if (bs1 != null)
                    // write("<a href=\""+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
                    // else
                    // write("<a href=\"valueset-"+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
                    } else
                        throw new Exception("Internal reference " + cd.getReference() + " not handled yet");
                } else if (cd.getReference().startsWith("http:"))
                    write("<a href=\"" + cd.getReference() + "\">" + cd.getReference() + "</a><!-- e -->");
                else
                    write("<a href=\"" + prefix + "valueset-" + cd.getReference() + ".html\">http://hl7.org/fhir/" + cd.getReference() + "</a><!-- e -->");
            } else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
                write("<a href=\"" + prefix + "valueset-" + cd.getReference().substring(1) + ".html\">http://hl7.org/fhir/" + cd.getReference().substring(1) + "</a><!-- f -->");
            }
            write("</td>");
        }
        write(" </tr>\r\n");
    }
    write("</table>\r\n<p> </p>\r\n");
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ArrayList(java.util.ArrayList) ValueSet(org.hl7.fhir.r5.model.ValueSet) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)51 ArrayList (java.util.ArrayList)41 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)36 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)27 Test (org.junit.jupiter.api.Test)23 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)20 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)18 Reference (org.hl7.fhir.r4.model.Reference)17 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)17 HashMap (java.util.HashMap)15 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)15 Coding (org.hl7.fhir.r4.model.Coding)14 Identifier (org.hl7.fhir.r4.model.Identifier)14 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)13 Patient (org.hl7.fhir.r4.model.Patient)13 IOException (java.io.IOException)12 Header (org.apache.http.Header)11 Test (org.junit.Test)11 File (java.io.File)10 URISyntaxException (java.net.URISyntaxException)10