use of org.hl7.fhir.r5.model in project kindling by HL7.
the class DSTU3ValidationConvertor method convert.
public void convert(String bundleSource, String bundleTarget) throws Exception {
System.out.println("Convert " + bundleSource);
try {
source = (Bundle) new XmlParser().parse(new FileInputStream(bundleSource));
org.hl7.fhir.dstu3.model.Bundle target = Bundle30_50.convertBundle(source);
new org.hl7.fhir.dstu3.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(bundleTarget), target);
} catch (Exception e) {
throw new Exception(e);
}
}
use of org.hl7.fhir.r5.model in project kindling by HL7.
the class SourceParser method loadCompositeType.
private String loadCompositeType(String n, Map<String, org.hl7.fhir.definitions.model.TypeDefn> map, String fmm, boolean isAbstract) throws Exception {
TypeParser tp = new TypeParser(version.toString());
List<TypeRef> ts = tp.parse(n, false, null, context, true);
definitions.getKnownTypes().addAll(ts);
StandardsStatus status = loadStatus(n);
String nv = loadNormativeVersion(n);
try {
TypeRef t = ts.get(0);
File csv = new CSFile(dtDir + t.getName().toLowerCase() + ".xml");
if (csv.exists()) {
OldSpreadsheetParser p = new OldSpreadsheetParser("core", new CSFileInputStream(csv), csv.getName(), csv.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, true, ini, wg("fhir"), definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
org.hl7.fhir.definitions.model.TypeDefn el = p.parseCompositeType();
el.setFmmLevel(fmm);
el.setStandardsStatus(status);
el.setNormativeVersion(nv);
map.put(t.getName(), el);
genTypeProfile(el);
errors.addAll(p.getErrors());
return el.getName();
} else {
String p = ini.getStringProperty("types", n);
csv = new CSFile(dtDir + p.toLowerCase() + ".xml");
if (!csv.exists())
throw new Exception("unable to find a definition for " + n + " in " + p);
XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(csv), csv.getAbsolutePath());
new XLSXmlNormaliser(csv.getAbsolutePath(), exceptionIfExcelNotNormalised).go();
Sheet sheet = xls.getSheets().get("Restrictions");
boolean found = false;
for (int i = 0; i < sheet.rows.size(); i++) {
if (sheet.getColumn(i, "Name").equals(n)) {
found = true;
Invariant inv = new Invariant();
inv.setId(n);
inv.setEnglish(sheet.getColumn(i, "Rules"));
inv.setOcl(sheet.getColumn(i, "OCL"));
inv.setXpath(sheet.getColumn(i, "XPath"));
inv.setExpression(sheet.getColumn(i, "Expression"));
inv.setExplanation(sheet.getColumn(i, "Explanation"));
inv.setTurtle(sheet.getColumn(i, "RDF"));
ProfiledType pt = new ProfiledType();
pt.setDefinition(sheet.getColumn(i, "Definition"));
pt.setDescription(sheet.getColumn(i, "Rules"));
String structure = sheet.getColumn(i, "Structure");
if (!Utilities.noString(structure)) {
String[] parts = structure.split("\\;");
for (String pp : parts) {
String[] words = pp.split("\\=");
pt.getRules().put(words[0], words[1]);
}
}
pt.setName(n);
pt.setBaseType(p);
pt.setInvariant(inv);
definitions.getConstraints().put(n, pt);
}
}
if (!found)
throw new Exception("Unable to find definition for " + n);
return n;
}
} catch (Exception e) {
throw new Exception("Unable to load " + n + ": " + e.getMessage(), e);
}
}
use of org.hl7.fhir.r5.model in project kindling by HL7.
the class SourceParser method genTypeProfile.
private void genTypeProfile(org.hl7.fhir.definitions.model.TypeDefn t) throws Exception {
StructureDefinition profile;
try {
profile = new ProfileGenerator(definitions, context, page, genDate, version, null, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(t);
t.setProfile(profile);
DataTypeTableGenerator dtg = new DataTypeTableGenerator(dstDir, page, t.getName(), true, version);
t.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
t.getProfile().getText().getDiv().getChildNodes().add(dtg.generate(t, null, false));
if (context.hasResource(StructureDefinition.class, t.getProfile().getUrl()))
throw new Exception("Duplicate Profile " + t.getProfile().getUrl());
context.cacheResource(t.getProfile());
} catch (Exception e) {
throw new Exception("Error generating profile for '" + t.getName() + "': " + e.getMessage(), e);
}
}
use of org.hl7.fhir.r5.model in project kindling by HL7.
the class ImplementationGuideDefn method genToc.
public TableModel genToc(HierarchicalTableGenerator gen, String id) throws FHIRException {
TableModel model = gen.new TableModel(id, true);
model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Table Of Contents", null, null, 0));
addPage(gen, model.getRows(), ig.getDefinition().getPage());
return model;
}
use of org.hl7.fhir.r5.model 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;
}
Aggregations