Search in sources :

Example 1 with ProfileGenerator

use of org.hl7.fhir.definitions.generators.specification.ProfileGenerator in project kindling by HL7.

the class Publisher method genXhtmlProfile.

private void genXhtmlProfile() throws Exception {
    StructureDefinition profile = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generateXhtml();
    if (page.getProfiles().has(profile.getUrl()))
        throw new Exception("Duplicate Profile URL " + profile.getUrl());
    page.getProfiles().see(profile, page.packageInfo());
// DataTypeTableGenerator dtg = new DataTypeTableGenerator(page.getFolders().dstDir, page, t.getCode(), true);
// t.setProfile(profile);
// t.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
// t.getProfile().getText().getDiv().getChildNodes().add(dtg.generate(t));
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) 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 ProfileGenerator

use of org.hl7.fhir.definitions.generators.specification.ProfileGenerator in project kindling by HL7.

the class Publisher method genProfiledTypeProfile.

private void genProfiledTypeProfile(ProfiledType pt) throws Exception {
    StructureDefinition profile = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(pt, page.getValidationErrors());
    if (page.getProfiles().has(profile.getUrl()))
        throw new Exception("Duplicate Profile URL " + profile.getUrl());
    page.getProfiles().see(profile, page.packageInfo());
    pt.setProfile(profile);
// todo: what to do in the narrative?
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 3 with ProfileGenerator

use of org.hl7.fhir.definitions.generators.specification.ProfileGenerator in project kindling by HL7.

the class Publisher method genPrimitiveTypeProfile.

private void genPrimitiveTypeProfile(PrimitiveType t) throws Exception {
    StructureDefinition profile = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(t);
    if (page.getProfiles().has(profile.getUrl()))
        throw new Exception("Duplicate Profile URL " + profile.getUrl());
    page.getProfiles().see(profile, page.packageInfo());
    t.setProfile(profile);
// DataTypeTableGenerator dtg = new DataTypeTableGenerator(page.getFolders().dstDir, page, t.getCode(), true);
// t.setProfile(profile);
// t.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
// t.getProfile().getText().getDiv().getChildNodes().add(dtg.generate(t));
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 4 with ProfileGenerator

use of org.hl7.fhir.definitions.generators.specification.ProfileGenerator in project kindling by HL7.

the class Publisher method processProfiles.

@SuppressWarnings("unchecked")
private void processProfiles() throws Exception {
    page.log(" ...process profiles (base)", LogMessageType.Process);
    // first, for each type and resource, we build it's master profile
    for (DefinedCode t : page.getDefinitions().getPrimitives().values()) {
        if (t instanceof PrimitiveType)
            genPrimitiveTypeProfile((PrimitiveType) t);
        else
            genPrimitiveTypeProfile((DefinedStringPattern) t);
    }
    genXhtmlProfile();
    for (TypeDefn t : page.getDefinitions().getTypes().values()) genTypeProfile(t);
    for (TypeDefn t : page.getDefinitions().getInfrastructure().values()) genTypeProfile(t);
    page.log(" ...process profiles (resources)", LogMessageType.Process);
    for (ResourceDefn r : page.getDefinitions().getBaseResources().values()) {
        r.setConformancePack(makeConformancePack(r));
        r.setProfile(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(r.getConformancePack(), r, "core", false));
        if (page.getProfiles().has(r.getProfile().getUrl()))
            throw new Exception("Duplicate Profile URL " + r.getProfile().getUrl());
        page.getProfiles().see(r.getProfile(), page.packageInfo());
        ResourceTableGenerator rtg = new ResourceTableGenerator(page.getFolders().dstDir, page, null, true, page.getVersion());
        r.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        r.getProfile().getText().getDiv().getChildNodes().add(rtg.generate(r, "", false));
    }
    for (String rn : page.getDefinitions().sortedResourceNames()) {
        ResourceDefn r = page.getDefinitions().getResourceByName(rn);
        r.setConformancePack(makeConformancePack(r));
        r.setProfile(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(r.getConformancePack(), r, "core", false));
        if (page.getProfiles().has(r.getProfile().getUrl()))
            throw new Exception("Duplicate Profile URL " + r.getProfile().getUrl());
        page.getProfiles().see(r.getProfile(), page.packageInfo());
        ResourceTableGenerator rtg = new ResourceTableGenerator(page.getFolders().dstDir, page, null, true, page.getVersion());
        r.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        r.getProfile().getText().getDiv().getChildNodes().add(rtg.generate(r, "", false));
    }
    for (ResourceDefn r : page.getDefinitions().getResourceTemplates().values()) {
        r.setConformancePack(makeConformancePack(r));
        r.setProfile(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(r.getConformancePack(), r, "core", true));
        ResourceTableGenerator rtg = new ResourceTableGenerator(page.getFolders().dstDir, page, null, true, page.getVersion());
        r.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        r.getProfile().getText().getDiv().getChildNodes().add(rtg.generate(r, "", true));
        if (page.getProfiles().has(r.getProfile().getUrl()))
            throw new Exception("Duplicate Profile URL " + r.getProfile().getUrl());
        page.getProfiles().see(r.getProfile(), page.packageInfo());
    }
    for (ProfiledType pt : page.getDefinitions().getConstraints().values()) {
        genProfiledTypeProfile(pt);
    }
    page.log(" ...process profiles (extensions)", LogMessageType.Process);
    for (StructureDefinition ex : page.getWorkerContext().getExtensionDefinitions()) processExtension(ex);
    for (ResourceDefn r : page.getDefinitions().getResources().values()) {
        // boolean logged = false;
        for (Profile ap : r.getConformancePackages()) {
            // logged = true;
            for (ConstraintStructure p : ap.getProfiles()) processProfile(ap, p, ap.getId(), r);
        }
    }
    page.log(" ...process profiles (packs)", LogMessageType.Process);
    // we have profiles scoped by resources, and stand alone profiles
    for (Profile ap : page.getDefinitions().getPackList()) {
        // page.log(" ...  pack "+ap.getId(), LogMessageType.Process);
        for (ConstraintStructure p : ap.getProfiles()) processProfile(ap, p, ap.getId(), null);
    }
    page.log(" ...process logical models", LogMessageType.Process);
    for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) {
        for (LogicalModel lm : ig.getLogicalModels()) {
            page.log(" ...process logical model " + lm.getId(), LogMessageType.Process);
            if (lm.getDefinition() == null)
                lm.setDefinition(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generateLogicalModel(ig, lm.getResource()));
        }
    }
    // now, validate the profiles
    for (Profile ap : page.getDefinitions().getPackList()) for (ConstraintStructure p : ap.getProfiles()) validateProfile(p);
    for (ResourceDefn r : page.getDefinitions().getResources().values()) for (Profile ap : r.getConformancePackages()) for (ConstraintStructure p : ap.getProfiles()) validateProfile(p);
    page.log(" ...Check FHIR Path Expressions", LogMessageType.Process);
    StringBuilder b = new StringBuilder();
    FHIRPathEngine fp = new FHIRPathEngine(page.getWorkerContext());
    fp.setHostServices(page.getExpressionResolver());
    for (FHIRPathUsage p : fpUsages) {
        checkExpression(b, fp, p);
    }
    TextFile.stringToFile(b.toString(), Utilities.path(page.getFolders().dstDir, "fhirpaths.txt"));
    checkAllOk();
}
Also used : TypeDefn(org.hl7.fhir.definitions.model.TypeDefn) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FHIRPathEngine(org.hl7.fhir.r5.utils.FHIRPathEngine) ResourceTableGenerator(org.hl7.fhir.definitions.generators.specification.ResourceTableGenerator) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Profile(org.hl7.fhir.definitions.model.Profile) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) LogicalModel(org.hl7.fhir.definitions.model.LogicalModel) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinedStringPattern(org.hl7.fhir.definitions.model.DefinedStringPattern) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) PrimitiveType(org.hl7.fhir.definitions.model.PrimitiveType) FHIRPathUsage(org.hl7.fhir.definitions.validation.FHIRPathUsage) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Example 5 with ProfileGenerator

use of org.hl7.fhir.definitions.generators.specification.ProfileGenerator in project kindling by HL7.

the class Publisher method buildSearchDefinition.

private void buildSearchDefinition(ResourceDefn rd, SearchParameterDefn spd) throws Exception {
    StructureDefinition p = new StructureDefinition();
    p.setFhirVersion(page.getVersion());
    p.setKind(StructureDefinitionKind.RESOURCE);
    p.setAbstract(true);
    p.setPublisher("Health Level Seven International (" + rd.getWg() + ")");
    p.setName(rd.getName());
    p.setVersion(page.getVersion().toCode());
    p.setType(rd.getName());
    p.addContact().addTelecom().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
    SearchParameter sp = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).makeSearchParam(p, rd.getName() + "-" + spd.getCode(), rd.getName(), spd, rd);
    spd.setResource(sp);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) SearchParameter(org.hl7.fhir.r5.model.SearchParameter)

Aggregations

ProfileGenerator (org.hl7.fhir.definitions.generators.specification.ProfileGenerator)12 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)11 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 FileNotFoundException (java.io.FileNotFoundException)8 IOException (java.io.IOException)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 TransformerException (javax.xml.transform.TransformerException)7 FileOutputStream (java.io.FileOutputStream)3 JsonParser (org.hl7.fhir.r5.formats.JsonParser)3 XmlParser (org.hl7.fhir.r5.formats.XmlParser)3 CSFile (org.hl7.fhir.utilities.CSFile)3 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)3 DataTypeTableGenerator (org.hl7.fhir.definitions.generators.specification.DataTypeTableGenerator)2 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)2 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)2 ProfileUtilities (org.hl7.fhir.r5.conformance.ProfileUtilities)2 RdfParser (org.hl7.fhir.r5.formats.RdfParser)2 ArrayList (java.util.ArrayList)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ResourceTableGenerator (org.hl7.fhir.definitions.generators.specification.ResourceTableGenerator)1