Search in sources :

Example 16 with Base

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

the class PageProcessor method elHeader.

private String elHeader(String mode) {
    StringBuilder b = new StringBuilder();
    b.append("<ul class=\"nav nav-tabs\">");
    b.append(makeHeaderTab("Element", "element.html", mode == null || "base".equals(mode)));
    b.append(makeHeaderTab("Detailed Descriptions", "element-definitions.html", mode == null || "definitions".equals(mode)));
    b.append(makeHeaderTab("Extensions", "element-extras.html", mode == null || "extensions".equals(mode)));
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 17 with Base

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

the class Publisher method getIgProfile.

public StructureDefinition getIgProfile(String base) throws Exception {
    String[] parts = base.split("#");
    StructureDefinition p = getIGProfileByURL(parts[0]);
    if (p == null)
        return null;
    // this is recursive, but will terminate at the root
    processProfile(p);
    if (parts.length == 1) {
        if (p.getSnapshot() == null)
            // or else we could fill it in?
            throw new Exception("StructureDefinition " + base + " has no snapshot");
        return p;
    }
    for (Resource r : p.getContained()) {
        if (r instanceof StructureDefinition && r.getId().equals(parts[1])) {
            StructureDefinition pc = (StructureDefinition) r;
            if (pc.getSnapshot() == null) {
                StructureDefinition ps = getSnapShotForProfile(pc.getBaseDefinition());
                processProfile(pc);
            }
            return pc;
        }
    }
    throw new Exception("Unable to find snapshot for " + base);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Resource(org.hl7.fhir.r5.model.Resource) DomainResource(org.hl7.fhir.r5.model.DomainResource) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 18 with Base

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

the class Publisher method processProfile.

private void processProfile(Profile ap, ConstraintStructure profile, String filename, ResourceDefn baseResource) throws Exception {
    // create StructureDefinition structures if needed (create differential definitions from spreadsheets)
    if (profile.getResource() == null) {
        StructureDefinition p = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(ap, profile, profile.getDefn(), profile.getId(), profile.getUsage(), page.getValidationErrors(), baseResource);
        p.setUserData("pack", ap);
        profile.setResource(p);
        if (profile.getResourceInfo() != null) {
            profile.getResourceInfo().setUserData(ToolResourceUtilities.RES_ACTUAL_RESOURCE, p);
        }
        if (page.getProfiles().has(p.getUrl()))
            throw new Exception("Duplicate Profile URL " + p.getUrl());
        page.getProfiles().see(p, page.packageInfo());
    } else {
        profile.getResource().setUserData("pack", ap);
        sortProfile(profile.getResource());
        for (ElementDefinition ed : profile.getResource().getDifferential().getElement()) if (!ed.hasId())
            throw new Exception("Missing ID");
        // special case: if the profile itself doesn't claim a date, it's date is the date of this publication
        if (!profile.getResource().hasDate())
            profile.getResource().setDate(page.getGenDate().getTime());
        if (profile.getResource().hasBaseDefinition() && !profile.getResource().hasSnapshot()) {
            // cause it probably doesn't, coming from the profile directly
            StructureDefinition base = getSnapShotForProfile(profile.getResource().getBaseDefinition());
            new ProfileUtilities(page.getWorkerContext(), page.getValidationErrors(), page).generateSnapshot(base, profile.getResource(), profile.getResource().getBaseDefinition().split("#")[0], "http://hl7.org/fhir", profile.getResource().getName());
        }
        if (page.getProfiles().has(profile.getResource().getUrl()))
            throw new Exception("Duplicate Profile URL " + profile.getResource().getUrl());
        System.out.println("register " + profile.getResource().getUrl());
        page.getProfiles().see(profile.getResource(), page.packageInfo());
    }
    if (!Utilities.noString(filename))
        profile.getResource().setUserData("filename", filename + ".html");
    if (Utilities.noString(profile.getResource().getUserString("path"))) {
        String path = "";
        ImplementationGuideDefn ig = page.getDefinitions().getUsageIG(ap.getCategory(), "processProfile");
        if (ig != null && !ig.isCore())
            path = ig.getCode() + File.separator;
        profile.getResource().setUserData("path", path + filename + ".html");
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 19 with Base

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

the class PageProcessor method refHeader.

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

Example 20 with Base

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

the class PageProcessor method resourcesHeader.

private String resourcesHeader(String mode) {
    StringBuilder b = new StringBuilder();
    b.append("<ul class=\"nav nav-tabs\">");
    b.append(makeHeaderTab("Resource Definitions", "resource.html", mode == null || "base".equals(mode)));
    b.append(makeHeaderTab("Examples", "resources-examples.html", mode == null || "examples".equals(mode)));
    b.append(makeHeaderTab("Detailed Descriptions", "resources-definitions.html", mode == null || "definitions".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