Search in sources :

Example 66 with EOperationOutcome

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() + ")");
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) Resource(org.hl7.fhir.r5.model.Resource) CapabilityStatement(org.hl7.fhir.r5.model.CapabilityStatement) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource)

Example 67 with EOperationOutcome

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);
}
Also used : CodeType(org.hl7.fhir.dstu2.model.CodeType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 68 with EOperationOutcome

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);
        }
    }
}
Also used : Reference(org.hl7.fhir.dstu2.model.Reference) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) OperationDefinitionParameterComponent(org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent)

Example 69 with EOperationOutcome

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();
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) DomainResource(org.hl7.fhir.r5.model.DomainResource) FileOutputStream(java.io.FileOutputStream)

Example 70 with EOperationOutcome

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);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) ArrayList(java.util.ArrayList) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) ElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent) Test(org.junit.jupiter.api.Test)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)52 FHIRException (org.hl7.fhir.exceptions.FHIRException)38 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)37 ArrayList (java.util.ArrayList)35 ProfileUtilities (org.hl7.fhir.dstu3.conformance.ProfileUtilities)14 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)13 StructureDefinition (org.hl7.fhir.dstu2.model.StructureDefinition)13 ProfileUtilities (org.hl7.fhir.dstu2.utils.ProfileUtilities)13 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)13 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)13 FileOutputStream (java.io.FileOutputStream)10 Test (org.junit.jupiter.api.Test)10 IOException (java.io.IOException)9 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)9 DomainResource (org.hl7.fhir.r5.model.DomainResource)7 DomainResource (org.hl7.fhir.r4b.model.DomainResource)6 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)6 BaseWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper)6 BaseWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper)6 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)5