Search in sources :

Example 31 with ImplementationGuideDefn

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

the class ResourceParser method processProfile.

private ConstraintStructure processProfile(String rid, String igId, ImplementationGuideDefinitionResourceComponent res, WorkGroup wg) throws FHIRFormatError, FileNotFoundException, IOException {
    StructureDefinition sd = (StructureDefinition) parseXml("structuredefinition-profile-" + rid + ".xml");
    ImplementationGuideDefn ig = definitions.getIgs().get(BuildExtensions.readStringExtension(res, igId));
    if (ig == null) {
        ig = definitions.getIgs().get("core");
    }
    ConstraintStructure cs = new ConstraintStructure(sd, ig, wg == null ? wg(sd) : wg, null, false);
    return cs;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Example 32 with ImplementationGuideDefn

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

the class IgParser method processPage.

private void processPage(ImplementationGuideDefinitionPageComponent page, ImplementationGuideDefn igd) throws Exception {
    if (!page.hasTitle())
        throw new Exception("Page " + page.getNameUrlType().getValue() + " has no name");
    if (getKind(page) == null || getKind(page) == GuidePageKind.PAGE || getKind(page) == GuidePageKind.DIRECTORY || getKind(page) == GuidePageKind.LIST || getKind(page) == GuidePageKind.RESOURCE) {
        checkExists(igd, page.getNameUrlType().getValue());
        igd.getPageList().add(page.getNameUrlType().getValue());
    }
    for (ImplementationGuideDefinitionPageComponent pp : page.getPage()) {
        processPage(pp, igd);
    }
}
Also used : ImplementationGuideDefinitionPageComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent)

Example 33 with ImplementationGuideDefn

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

the class Publisher method copyIgImage.

private void copyIgImage(ImplementationGuideDefn ig, String path) throws IOException {
    File file = new File(Utilities.path(page.getFolders().rootDir, ig.getSource(), "..", path));
    String prefix = ig.isCore() ? "" : ig.getCode() + File.separator;
    if (path.contains("*")) {
        final String filter = file.getName().replace("?", ".?").replace("*", ".*?");
        File[] files = new File(file.getParent()).listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.matches(filter);
            }
        });
        for (File f : files) {
            Utilities.copyFile(f, new CSFile(Utilities.path(page.getFolders().dstDir, prefix + f.getName())));
            page.getHTMLChecker().registerFile(prefix + f.getName(), "Support File", HTMLLinkChecker.determineType(f.getName()), true);
        }
    } else {
        Utilities.copyFile(file, new CSFile(Utilities.path(page.getFolders().dstDir, prefix + file.getName())));
        page.getHTMLChecker().registerFile(prefix + file.getName(), "Support File", HTMLLinkChecker.determineType(file.getName()), true);
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) CSFile(org.hl7.fhir.utilities.CSFile) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Example 34 with ImplementationGuideDefn

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

the class ProfileGenerator method generateLogicalModel.

public StructureDefinition generateLogicalModel(ImplementationGuideDefn igd, ResourceDefn r) throws Exception {
    StructureDefinition p = new StructureDefinition();
    p.setId(r.getRoot().getName());
    p.setUrl("http://hl7.org/fhir/StructureDefinition/" + r.getRoot().getName());
    p.setKind(StructureDefinitionKind.LOGICAL);
    p.setAbstract(false);
    p.setUserData("filename", r.getName().toLowerCase());
    p.setUserData("path", igd.getPrefix() + r.getName().toLowerCase() + ".html");
    p.setTitle(r.getName());
    p.setFhirVersion(version);
    p.setVersion(version.toCode());
    p.setType(r.getRoot().getName());
    ToolingExtensions.setStandardsStatus(p, r.getStatus(), null);
    ToolResourceUtilities.updateUsage(p, igd.getCode());
    p.setName(r.getRoot().getName());
    p.setPublisher("Health Level Seven International" + (r.getWg() == null ? " " + igd.getCommittee() : " (" + r.getWg().getName() + ")"));
    p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
    if (r.getWg() != null) {
        p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, r.getWg().getUrl()));
        ToolingExtensions.setCodeExtension(p, ToolingExtensions.EXT_WORKGROUP, r.getWg().getCode());
    }
    p.setDescription("Logical Model: " + r.getDefinition());
    p.setPurpose(r.getRoot().getRequirements());
    if (!p.hasPurpose())
        p.setPurpose(r.getRoot().getRequirements());
    p.setDate(genDate.getTime());
    // DSTU
    p.setStatus(PublicationStatus.fromCode("draft"));
    Set<String> containedSlices = new HashSet<String>();
    // first, the differential
    p.setSnapshot(new StructureDefinitionSnapshotComponent());
    defineElement(null, p, p.getSnapshot().getElement(), r.getRoot(), r.getRoot().getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.None, true, "Element", "Element", true);
    addElementConstraintToSnapshot(p);
    XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
    div.addText("to do");
    p.setText(new Narrative());
    p.getText().setStatus(NarrativeStatus.GENERATED);
    p.getText().setDiv(div);
    return p;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Narrative(org.hl7.fhir.r5.model.Narrative) StructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent) HashSet(java.util.HashSet) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 35 with ImplementationGuideDefn

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

the class PatternFinder method findMatchingPattern.

private String findMatchingPattern(String p) {
    // try and find a direct pattern match
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        for (LogicalModel lm : ig.getLogicalModels()) {
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String s : lm.getImplementations()) b.append(s);
            if (b.toString().equals(p))
                return "<a href=\"" + lm.getResource().getName() + ".html#" + lm.getResource().getRoot().getName() + "\">" + lm.getResource().getRoot().getName() + "</a>";
        }
    }
    String[] pl = p.split("\\,");
    Set<String> ps = new HashSet<>();
    for (String s : pl) ps.add(s.trim());
    // note any close patterns
    CommaSeparatedStringBuilder pb = new CommaSeparatedStringBuilder("<br/>");
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        for (LogicalModel lm : ig.getLogicalModels()) {
            Set<String> bs = new HashSet<>();
            for (String s : lm.getImplementations()) bs.add(s);
            if (!bs.isEmpty()) {
                Set<String> missed = new HashSet<>();
                Set<String> extra = new HashSet<>();
                Utilities.analyseStringDiffs(ps, bs, missed, extra);
                if (missed.size() + extra.size() <= 3) {
                    String s = "<a href=\"" + lm.getResource().getName() + ".html#" + lm.getResource().getRoot().getName() + "\">" + lm.getResource().getRoot().getName() + "</a>";
                    if (missed.size() > 0)
                        s = s + " + " + missed.toString();
                    if (extra.size() > 0)
                        s = s + " - " + extra.toString();
                    pb.append(s);
                }
            }
        }
    }
    return pb.toString();
}
Also used : LogicalModel(org.hl7.fhir.definitions.model.LogicalModel) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) HashSet(java.util.HashSet)

Aggregations

ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)34 FHIRException (org.hl7.fhir.exceptions.FHIRException)25 FileNotFoundException (java.io.FileNotFoundException)22 IOException (java.io.IOException)22 TransformerException (javax.xml.transform.TransformerException)21 CSFile (org.hl7.fhir.utilities.CSFile)21 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)19 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)18 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)17 File (java.io.File)16 ArrayList (java.util.ArrayList)16 Profile (org.hl7.fhir.definitions.model.Profile)16 ValueSet (org.hl7.fhir.r5.model.ValueSet)15 IniFile (org.hl7.fhir.utilities.IniFile)15 TextFile (org.hl7.fhir.utilities.TextFile)15 Example (org.hl7.fhir.definitions.model.Example)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)11 URISyntaxException (java.net.URISyntaxException)11 HashMap (java.util.HashMap)10 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)10