use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilitiesTests method testSimple2.
/**
* This is simple: we just create an empty differential, generate the snapshot, and then insist it must match the base. for a different resource with recursion
*
* @param context2
* @
* @throws EOperationOutcome
*/
private void testSimple2() throws EOperationOutcome, Exception {
StructureDefinition focus = new StructureDefinition();
StructureDefinition base = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet").copy();
focus.setUrl(Utilities.makeUuidUrn());
focus.setBase(base.getUrl());
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
new ProfileUtilities(context, messages, null).generateSnapshot(base, focus, focus.getUrl(), "Simple Test");
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
if (ok) {
ElementDefinition b = base.getSnapshot().getElement().get(i);
ElementDefinition f = focus.getSnapshot().getElement().get(i);
if (!f.hasBase() || !b.getPath().equals(f.getBase().getPath()))
ok = false;
else {
f.setBase(null);
ok = Base.compareDeep(b, f, true);
}
}
}
if (!ok) {
compareXml(base, focus);
throw new FHIRException("Snap shot generation simple test failed");
} else
System.out.println("Snap shot generation simple test passed");
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGeneratorTests method process.
private void process(String path) throws IOException, EOperationOutcome, FHIRException {
XmlParser p = new XmlParser();
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
gen.generate(r);
FileOutputStream s = new FileOutputStream(Utilities.path("[tmp]", "gen.xml"));
new XmlParser().compose(s, r, true);
s.close();
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method genOpParam.
private void genOpParam(XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode tr;
tr = tbl.addTag("tr");
tr.addTag("td").addText(p.getUse().toString());
tr.addTag("td").addText(path + p.getName());
tr.addTag("td").addText(Integer.toString(p.getMin()) + ".." + p.getMax());
tr.addTag("td").addText(p.hasType() ? p.getType() : "");
XhtmlNode td = tr.addTag("td");
if (p.hasBinding() && p.getBinding().hasValueSet()) {
if (p.getBinding().getValueSet() instanceof Reference)
AddVsRef(p.getBinding().getValueSetReference().getReference(), td);
else
td.addTag("a").setAttribute("href", p.getBinding().getValueSetUriType().getValue()).addText("External Reference");
td.addText(" (" + p.getBinding().getStrength().getDisplay() + ")");
}
addMarkdown(tr.addTag("td"), p.getDocumentation());
if (!p.hasType()) {
for (OperationDefinitionParameterComponent pp : p.getPart()) {
genOpParam(tbl, path + p.getName() + ".", pp);
}
}
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGeneratorTests method process.
private void process(String path) throws FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
XmlParser p = new XmlParser();
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
gen.generate(r);
FileOutputStream s = new FileOutputStream(Utilities.path("[tmp]", "gen.xml"));
new XmlParser().compose(s, r, true);
s.close();
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public boolean generate(ResourceContext rcontext, StructureDefinition sd, java.util.Set<String> outputTracker) throws EOperationOutcome, FHIRException, IOException {
ProfileUtilities pu = new ProfileUtilities(context, null, pkp);
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.getChildNodes().add(pu.generateTable(definitionsTarget, sd, true, destDir, false, sd.getId(), false, corePath, "", false, false, outputTracker));
inject(sd, x, NarrativeStatus.GENERATED);
return true;
}
Aggregations