use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class ValidatorUtils method messagesToOutcome.
protected static OperationOutcome messagesToOutcome(List<ValidationMessage> messages, SimpleWorkerContext context, FHIRPathEngine fpe) throws IOException, FHIRException, EOperationOutcome {
OperationOutcome op = new OperationOutcome();
for (ValidationMessage vm : filterMessages(messages)) {
try {
fpe.parse(vm.getLocation());
} catch (Exception e) {
System.out.println("Internal error in location for message: '" + e.getMessage() + "', loc = '" + vm.getLocation() + "', err = '" + vm.getMessage() + "'");
}
op.getIssue().add(OperationOutcomeUtilities.convertToIssue(vm, op));
}
if (!op.hasIssue()) {
op.addIssue().setSeverity(OperationOutcome.IssueSeverity.INFORMATION).setCode(OperationOutcome.IssueType.INFORMATIONAL).getDetails().setText(context.formatMessage(I18nConstants.ALL_OK));
}
RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, RenderingContext.ResourceRendererMode.END_USER);
RendererFactory.factory(op, rc).render(op);
return op;
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method genOpParam.
private void genOpParam(ResourceContext rcontext, XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode tr;
tr = tbl.tr();
tr.td().addText(p.getUse().toString());
tr.td().addText(path + p.getName());
tr.td().addText(Integer.toString(p.getMin()) + ".." + p.getMax());
tr.td().addText(p.hasType() ? p.getType() : "");
XhtmlNode td = tr.td();
if (p.hasBinding() && p.getBinding().hasValueSet()) {
if (p.getBinding().getValueSet() instanceof Reference)
AddVsRef(rcontext, p.getBinding().getValueSetReference().getReference(), td);
else
td.ah(p.getBinding().getValueSetUriType().getValue()).tx("External Reference");
td.tx(" (" + p.getBinding().getStrength().getDisplay() + ")");
}
addMarkdown(tr.td(), p.getDocumentation());
if (!p.hasType()) {
for (OperationDefinitionParameterComponent pp : p.getPart()) {
genOpParam(rcontext, tbl, path + p.getName() + ".", pp);
}
}
}
use of org.hl7.fhir.r5.utils.EOperationOutcome in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilitiesTests method testSimple.
// /**
// * This is simple: we just create an empty differential, generate the snapshot, and then insist it must match the base
// *
// * @param context2
// * @
// * @throws EOperationOutcome
// */
@Test
public void testSimple() throws FHIRException, FileNotFoundException, IOException, UcumException {
StructureDefinition focus = new StructureDefinition();
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
focus.setUrl(Utilities.makeUuidUrn());
focus.setBaseDefinition(base.getUrl());
focus.setType("Patient");
focus.setDerivation(TypeDerivationRule.CONSTRAINT);
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://hl7.org/fhir/R4", "Simple Test");
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
ElementDefinition b = base.getSnapshot().getElement().get(i);
ElementDefinition f = focus.getSnapshot().getElement().get(i);
if (ok) {
if (!f.hasBase())
ok = false;
else if (!b.getPath().equals(f.getPath()))
ok = false;
else {
b.setBase(null);
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 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() throws EOperationOutcome, Exception {
StructureDefinition base = TestingUtilities.context().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<ValidationMessage>();
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://hl7.org/fhir/R4", "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.getPath()))
ok = false;
else {
f.setBase(null);
b.setBase(null);
ok = Base.compareDeep(b, f, true);
}
}
}
if (!ok) {
compareXml(base, focus);
System.out.println("Snap shot generation simple test failed");
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 FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
XmlParser p = new XmlParser();
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
gen.generate(r, null);
FileOutputStream s = new FileOutputStream(TestingUtilities.resourceNameToFile("gen", "gen.xml"));
new XmlParser().compose(s, r, true);
s.close();
}
Aggregations