use of org.hl7.fhir.definitions.model.WorkGroup in project kindling by HL7.
the class ResourceParser method convertPack.
private Profile convertPack(ImplementationGuide ig, String id, WorkGroup wg) throws Exception {
Profile p = new Profile(id.substring(id.indexOf("-") + 1));
p.setTitle(ig.getTitle());
p.forceMetadata("id", ig.getId());
if (ig.hasName()) {
p.forceMetadata("name", ig.getName());
}
if (ig.hasPublisher()) {
p.forceMetadata("author.name", ig.getPublisher());
}
if (ig.hasExtension(BuildExtensions.EXT_CODE)) {
p.forceMetadata("code", BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_CODE));
}
if (ig.hasExtension(BuildExtensions.EXT_FMM_LEVEL)) {
p.forceMetadata("fmm", BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_FMM_LEVEL));
}
if (ig.hasDescription()) {
p.forceMetadata("description", ig.getDescription());
}
if (ig.hasStatus()) {
p.forceMetadata("status", ig.getStatus().toCode());
}
if (ig.hasVersion()) {
p.forceMetadata("version", ig.getVersion());
}
if (ig.hasTitle()) {
p.forceMetadata("display", ig.getTitle());
}
if (ig.hasExtension(BuildExtensions.EXT_WORKGROUP)) {
p.forceMetadata("workgroup", BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_WORKGROUP));
}
if (ig.hasDate()) {
p.forceMetadata("date", ig.getDateElement().primitiveValue());
}
if (ig.hasExperimental()) {
p.forceMetadata("Experimental", ig.getExperimentalElement().primitiveValue());
}
if (ig.hasExtension(BuildExtensions.EXT_INTRODUCTION)) {
p.setIntroduction(Utilities.path(folder, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_INTRODUCTION)));
}
if (ig.hasExtension(BuildExtensions.EXT_NOTES)) {
p.setNotes(Utilities.path(folder, BuildExtensions.readStringExtension(ig, BuildExtensions.EXT_NOTES)));
}
for (ImplementationGuideDefinitionResourceComponent res : ig.getDefinition().getResource()) {
String ref = res.getReference().getReference();
String type = ref.substring(0, ref.indexOf("/"));
String rid = ref.substring(ref.indexOf("/") + 1);
if ("StructureDefinition".equals(type)) {
StructureDefinition sd;
if (new File(Utilities.path(folder, "structuredefinition-extension-" + rid + ".xml")).exists()) {
sd = (StructureDefinition) parseXml("structuredefinition-extension-" + rid + ".xml");
sd.setUserData("path", "extension-" + sd.getId() + ".html");
p.getExtensions().add(sd);
context.cacheResource(sd);
} else {
ConstraintStructure tp = processProfile(rid, ig.getId().substring(ig.getId().indexOf("-") + 1), res, wg);
sd = tp.getResource();
sd.setUserData("path", sd.getId() + ".html");
p.getProfiles().add(tp);
}
sd.setUserData(ToolResourceUtilities.NAME_RES_IG, id);
sd.setVersion(version);
for (ElementDefinition ed : sd.getDifferential().getElement()) {
if (ed.hasBinding() && ed.getBinding().hasValueSet()) {
loadValueSet(ed.getBinding().getValueSet(), true);
}
}
} else if ("SearchParameter".equals(type)) {
SearchParameter sp = processSearchParameter(rid);
p.getSearchParameters().add(sp);
} else {
// example
p.getExamples().add(makeExample(res, ref, type, rid));
}
}
return p;
}
use of org.hl7.fhir.definitions.model.WorkGroup in project kindling by HL7.
the class Publisher method producePage.
// private void validateProfile(ProfileDefn profile) throws FileNotFoundException, Exception {
// for (ResourceDefn c : profile.getResources()) {
// StructureDefinition resource = loadResourceProfile(c.getName());
// ProfileValidator v = new ProfileValidator();
// v.setCandidate(c);
// v.setProfile(resource);
// v.setTypes(typeFeed);
// List<String> errors = v.evaluate();
// if (errors.size() > 0)
// throw new Exception("Error validating " + profile.metadata("name") + ": " + errors.toString());
// }
// }
// private void produceFutureReference(String n) throws Exception {
// ElementDefn e = new ElementDefn();
// e.setName(page.getIni().getStringProperty("future-resources", n));
// }
/*
private StructureDefinition loadResourceProfile(String name) throws FileNotFoundException, Exception {
XmlParser xml = new XmlParser();
try {
return (StructureDefinition) xml.parse(new CSFileInputStream(page.getFolders().dstDir + name.toLowerCase() + ".profile.xml"));
} catch (Exception e) {
throw new Exception("error parsing " + name, e);
}
}
*/
// private void produceIgPage(String source, String file, String logicalName, ImplementationGuideDefn ig) throws Exception {
// String src = TextFile.fileToString(source);
// src = page.processPageIncludes(file, src, "page", null, null, null, logicalName, null);
// // before we save this page out, we're going to figure out what it's index
// // is, and number the headers if we can
//
// if (Utilities.noString(logicalName))
// logicalName = Utilities.fileTitle(file);
//
// TextFile.stringToFile(src, page.getFolders().dstDir + file);
// src = addSectionNumbers(file, logicalName, src, null, 0, null, ig);
//
// TextFile.stringToFile(src, page.getFolders().dstDir + file);
//
// src = TextFile.fileToString(source).replace("<body>", "<body style=\"margin: 10px\">");
// src = page.processPageIncludesForBook(file, src, "page", null, null);
// cachePage(file, src, logicalName);
// }
//
private void producePage(String file, String logicalName) throws Exception {
String src = TextFile.fileToString(page.getFolders().srcDir + file);
src = page.processPageIncludes(file, src, "page", null, null, null, logicalName, null, null, null);
if (Utilities.noString(logicalName))
logicalName = Utilities.fileTitle(file);
TextFile.stringToFile(src, page.getFolders().dstDir + file);
DocumentHolder doch = new DocumentHolder();
src = addSectionNumbers(file, logicalName, src, null, 0, doch, null);
if (!page.getDefinitions().getStructuralPages().contains(file)) {
XhtmlNode fmm = findId(doch.doc, "fmm");
XhtmlNode wg = findId(doch.doc, "wg");
if (fmm == null)
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.BUSINESSRULE, -1, -1, file, "Page has no fmm level", IssueSeverity.ERROR));
else
page.getDefinitions().page(file).setFmm(get2ndPart(fmm.allText()));
if (wg == null)
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.BUSINESSRULE, -1, -1, file, "Page has no workgroup", IssueSeverity.ERROR));
else
page.getDefinitions().page(file).setWg(wg.getChildNodes().get(0).allText());
}
TextFile.stringToFile(src, page.getFolders().dstDir + file);
src = TextFile.fileToString(page.getFolders().srcDir + file).replace("<body>", "<body style=\"margin: 10px\">");
src = page.processPageIncludesForBook(file, src, "page", null, null, null);
cachePage(file, src, logicalName, true);
}
Aggregations