use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class ComparisonService method doLeftRightComparison.
public static void doLeftRightComparison(String[] args, String dest, ValidationEngine validator) throws IOException, FHIRException, EOperationOutcome {
// ok now set up the comparison
String left = Params.getParam(args, Params.LEFT);
String right = Params.getParam(args, Params.RIGHT);
Resource resLeft = validator.getContext().fetchResource(Resource.class, left);
Resource resRight = validator.getContext().fetchResource(Resource.class, right);
if (resLeft == null) {
System.out.println("Unable to locate left resource " + left);
}
if (resRight == null) {
System.out.println("Unable to locate right resource " + right);
}
if (resLeft != null && resRight != null) {
if (resLeft instanceof StructureDefinition && resRight instanceof StructureDefinition) {
ComparisonService.compareStructureDefinitions(dest, validator, left, right, (StructureDefinition) resLeft, (StructureDefinition) resRight);
} else if (resLeft instanceof CapabilityStatement && resRight instanceof CapabilityStatement) {
ComparisonService.compareCapabilityStatements(args, dest, validator, left, right, (CanonicalResource) resLeft, (CanonicalResource) resRight);
} else
System.out.println("Unable to compare left resource " + left + " (" + resLeft.fhirType() + ") with right resource " + right + " (" + resRight.fhirType() + ")");
}
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public void generate(OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.addTag("h2").addText(opd.getName());
x.addTag("p").addText(Utilities.capitalize(opd.getKind().toString()) + ": " + opd.getName());
addMarkdown(x, opd.getDescription());
if (opd.getSystem())
x.addTag("p").addText("URL: [base]/$" + opd.getCode());
for (CodeType c : opd.getType()) {
x.addTag("p").addText("URL: [base]/" + c.getValue() + "/$" + opd.getCode());
if (opd.getInstance())
x.addTag("p").addText("URL: [base]/" + c.getValue() + "/[id]/$" + opd.getCode());
}
x.addTag("p").addText("Parameters");
XhtmlNode tbl = x.addTag("table").setAttribute("class", "grid");
XhtmlNode tr = tbl.addTag("tr");
tr.addTag("td").addTag("b").addText("Use");
tr.addTag("td").addTag("b").addText("Name");
tr.addTag("td").addTag("b").addText("Cardinality");
tr.addTag("td").addTag("b").addText("Type");
tr.addTag("td").addTag("b").addText("Binding");
tr.addTag("td").addTag("b").addText("Documentation");
for (OperationDefinitionParameterComponent p : opd.getParameter()) {
genOpParam(tbl, "", p);
}
addMarkdown(x, opd.getNotes());
inject(opd, x, NarrativeStatus.GENERATED);
}
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(InputStream stream) throws FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
XmlParser p = new XmlParser();
DomainResource r = (DomainResource) p.parse(stream);
RendererFactory.factory(r, rc).render(r);
FileOutputStream s = new FileOutputStream(TestingUtilities.tempFile("gen", "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 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
// */
@Test
public void testSimple2() {
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet").copy();
StructureDefinition focus = base.copy();
focus.setUrl(Utilities.makeUuidUrn());
focus.setSnapshot(null);
focus.setDifferential(null);
List<ValidationMessage> messages = new ArrayList<>();
new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "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);
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
c.setSource(null);
}
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
c.setSource(null);
}
if (!f.hasBase() || !b.getPath().equals(f.getPath()))
ok = false;
else {
f.setBase(null);
b.setBase(null);
b.setRequirements(null);
f.setRequirements(null);
b.setComment(null);
f.setComment(null);
b.setDefinition(null);
f.setDefinition(null);
b.setContentReference(null);
f.setContentReference(null);
ok = Base.compareDeep(b, f, true);
}
}
}
Assertions.assertTrue(ok);
}
Aggregations