Search in sources :

Example 76 with ResourceDefn

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

the class SchematronGenerator method generate.

public void generate(OutputStream out, ResourceDefn root, Definitions definitions) throws Exception {
    SchematronWriter sch = new SchematronWriter(out, SchematronType.RESOURCE, root.getName());
    insertGlobalRules(sch);
    Section s = sch.section(root.getName());
    ArrayList<String> parents = new ArrayList<String>();
    generateInvariants(s, null, root.getRoot(), definitions, parents, root.getName());
    sch.dump();
    sch.close();
}
Also used : SchematronWriter(org.hl7.fhir.utilities.xml.SchematronWriter) ArrayList(java.util.ArrayList) Section(org.hl7.fhir.utilities.xml.SchematronWriter.Section)

Example 77 with ResourceDefn

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

the class SchematronGenerator method generate.

public void generate(OutputStream out, Definitions definitions) throws Exception {
    SchematronWriter sch = new SchematronWriter(out, SchematronType.ALL_RESOURCES, "All Resources");
    insertGlobalRules(sch);
    for (String rn : definitions.sortedResourceNames()) {
        ResourceDefn root = definitions.getResources().get(rn);
        Section s = sch.section(root.getName());
        ArrayList<String> parents = new ArrayList<String>();
        generateInvariants(s, null, root.getRoot(), definitions, parents, root.getName());
    }
    Set<StructureDefinition> processed = new HashSet<StructureDefinition>();
    for (StructureDefinition exd : page.getWorkerContext().getExtensionDefinitions()) {
        if (exd.getSnapshot().getElement().get(0).hasConstraint() && !processed.contains(exd)) {
            processed.add(exd);
            Section s = sch.section("Extension: " + exd.getName());
            Rule r = s.rule("f:" + (exd.getSnapshot().getElementFirstRep().getIsModifier() ? "modifierExtension" : "extension") + "[@url='" + exd.getUrl() + "']");
            for (ElementDefinitionConstraintComponent inv : exd.getSnapshot().getElement().get(0).getConstraint()) {
                if (!isGlobal(inv.getKey()))
                    r.assrt(inv.getXpath().replace("\"", "'"), inv.getKey() + ": " + inv.getHuman());
            }
        }
    }
    sch.dump();
    sch.close();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) SchematronWriter(org.hl7.fhir.utilities.xml.SchematronWriter) ArrayList(java.util.ArrayList) Rule(org.hl7.fhir.utilities.xml.SchematronWriter.Rule) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Section(org.hl7.fhir.utilities.xml.SchematronWriter.Section) ElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent) HashSet(java.util.HashSet)

Example 78 with ResourceDefn

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

the class SvgGenerator method generate.

public void generate(ResourceDefn resource, String filename, String id) throws Exception {
    this.id = id;
    classes.clear();
    links.clear();
    XMLWriter xml = new XMLWriter(new FileOutputStream(filename), "UTF-8");
    generate(resource, xml);
}
Also used : FileOutputStream(java.io.FileOutputStream) XMLWriter(org.hl7.fhir.utilities.xml.XMLWriter)

Example 79 with ResourceDefn

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

the class MappingsGenerator method genInherited.

private void genInherited(StringBuilder s, ResourceDefn resource, String m) {
    for (StringPair t : resource.getMappings(m)) {
        s.append(" <tr><td><i>");
        s.append("&nbsp;");
        s.append("&nbsp;(");
        s.append(t.name.contains(".") ? t.name.substring(t.name.indexOf(".") + 1) : t.name);
        s.append(")</i></td><td>" + Utilities.escapeXml(t.value).replace("\n", "<br/>\n") + "</td></tr>\r\n");
    }
}
Also used : StringPair(org.hl7.fhir.definitions.model.ResourceDefn.StringPair)

Example 80 with ResourceDefn

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

the class PageProcessor method genAllSearchParams.

private String genAllSearchParams() throws Exception {
    List<SearchParameter> splist = new ArrayList<SearchParameter>();
    for (ResourceDefn rd : getDefinitions().getBaseResources().values()) addSearchParams(splist, rd);
    for (ResourceDefn rd : getDefinitions().getResources().values()) addSearchParams(splist, rd);
    for (Profile cp : getDefinitions().getPackList()) {
        addSearchParams(splist, cp);
    }
    StringBuilder b = new StringBuilder();
    genSearchParams(b, splist, "Resource");
    genSearchParams(b, splist, "DomainResource");
    genCommonSearchParams(b, splist);
    for (String n : definitions.sortedResourceNames()) genSearchParams(b, splist, n);
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Profile(org.hl7.fhir.definitions.model.Profile)

Aggregations

ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)75 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 ArrayList (java.util.ArrayList)38 FHIRException (org.hl7.fhir.exceptions.FHIRException)36 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)31 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)28 File (java.io.File)26 FileOutputStream (java.io.FileOutputStream)25 CSFile (org.hl7.fhir.utilities.CSFile)24 XmlParser (org.hl7.fhir.r5.formats.XmlParser)22 FileNotFoundException (java.io.FileNotFoundException)20 IOException (java.io.IOException)20 Example (org.hl7.fhir.definitions.model.Example)20 Profile (org.hl7.fhir.definitions.model.Profile)20 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)18 IniFile (org.hl7.fhir.utilities.IniFile)18 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)16 TransformerException (javax.xml.transform.TransformerException)15 TextFile (org.hl7.fhir.utilities.TextFile)15 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)14