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;
}
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);
}
}
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);
}
}
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;
}
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();
}
Aggregations