Search in sources :

Example 6 with CapabilityStatementRestResourceComponent

use of org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareProfiles.

private void compareProfiles(String path, StructuralMatch<Element> combined, CanonicalType left, CanonicalType right, CapabilityStatementComparison res, CapabilityStatementRestResourceComponent union, CapabilityStatementRestResourceComponent intersection) {
    if (!left.hasValue() && !right.hasValue()) {
    // nothing in this case
    } else if (!left.hasValue()) {
        // the intersection is anything in right. The union is everything (or nothing, in this case)
        intersection.setProfileElement(right.copy());
        combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.WARNING, "Added this profile", path), right).setName("profile"));
    } else if (!right.hasValue()) {
        // the intersection is anything in right. The union is everything (or nothing, in this case)
        intersection.setProfileElement(left.copy());
        combined.getChildren().add(new StructuralMatch<Element>(left, vmI(IssueSeverity.WARNING, "Removed this profile", path)).setName("profile"));
    } else {
        // profiles on both sides...
        StructureDefinition sdLeft = session.getContextLeft().fetchResource(StructureDefinition.class, left.getValue());
        StructureDefinition sdRight = session.getContextRight().fetchResource(StructureDefinition.class, right.getValue());
        if (sdLeft == null && sdRight == null) {
            combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.ERROR, "Cannot compare profiles because neither is known", path)).setName("profile"));
        } else if (sdLeft == null) {
            combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.ERROR, "Cannot compare profiles because '" + left.getValue() + "' is not known", path)).setName("profile"));
        } else if (sdRight == null) {
            combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.ERROR, "Cannot compare profiles because '" + right.getValue() + "' is not known", path)).setName("profile"));
        } else if (sdLeft.getUrl().equals(sdRight.getUrl())) {
            intersection.setProfileElement(left.copy());
            union.setProfileElement(left.copy());
            combined.getChildren().add(new StructuralMatch<Element>(left, right).setName("profile"));
        } else if (profileInherits(sdLeft, sdRight, session.getContextLeft())) {
            // if left inherits from right:
            intersection.setProfileElement(left.copy());
            union.setProfileElement(right.copy());
            combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.WARNING, "Changed this profile to a broader profile", path)).setName("profile"));
        } else if (profileInherits(sdRight, sdLeft, session.getContextRight())) {
            intersection.setProfileElement(right.copy());
            union.setProfileElement(left.copy());
            combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.WARNING, "Changed this profile to a narrower one", path)).setName("profile"));
        } else {
            combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.WARNING, "Different", path)).setName("profile"));
            throw new Error("Not done yet");
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) BackboneElement(org.hl7.fhir.r4b.model.BackboneElement) Element(org.hl7.fhir.r4b.model.Element)

Example 7 with CapabilityStatementRestResourceComponent

use of org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method intersectRestResource.

private CapabilityStatementRestResourceComponent intersectRestResource(CapabilityStatementRestResourceComponent l, CapabilityStatementRestResourceComponent r) {
    CapabilityStatementRestResourceComponent res = new CapabilityStatementRestResourceComponent();
    res.setType(l.getType());
    // todo: compare profiles, not just copy
    if (l.hasProfile() && l.getProfile().equals(r.getProfile())) {
        res.setProfile(l.getProfile());
    }
    if (l.hasDocumentation() && l.getDocumentation().equals(r.getDocumentation())) {
        res.setDocumentation(l.getDocumentation());
    }
    return res;
}
Also used : CapabilityStatementRestResourceComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent)

Example 8 with CapabilityStatementRestResourceComponent

use of org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.

the class OpenApiGenerator method generateSearch.

private void generateSearch(CapabilityStatementRestResourceComponent r) {
    OperationWriter op = makePathResType(r).operation("get");
    op.summary("Search all resources of type " + r.getType() + " based on a set of criteria");
    op.operationId("search" + r.getType());
    opOutcome(op.responses().defaultResponse());
    ResponseObjectWriter resp = op.responses().httpResponse("200");
    resp.description("the resource being returned");
    if (isJson())
        resp.content("application/fhir+json").schemaRef(specRef() + "/fhir.schema.json#/definitions/Bundle");
    if (isXml())
        resp.content("application/fhir+xml").schemaRef(specRef() + "/Bundle.xsd");
    // todo: how do we know that these apply?
    op.paramRef("#/components/parameters/format");
    op.paramRef("#/components/parameters/pretty");
    op.paramRef("#/components/parameters/summary");
    op.paramRef("#/components/parameters/elements");
    Set<String> set = new HashSet<>();
    for (CapabilityStatementRestResourceSearchParamComponent spc : r.getSearchParam()) {
        if (!set.contains(spc.getName())) {
            set.add(spc.getName());
            ParameterWriter p = op.parameter(spc.getName());
            p.in(ParameterLocation.query).description(spc.getDocumentation());
            p.schema().type(getSchemaType(spc.getType()));
            if (spc.hasDefinition()) {
                SearchParameter sp = context.fetchResource(SearchParameter.class, spc.getDefinition());
                if (sp != null) {
                    p.description(sp.getDescription());
                }
            }
        }
    }
}
Also used : CapabilityStatementRestResourceSearchParamComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent) SearchParameter(org.hl7.fhir.r4b.model.SearchParameter) HashSet(java.util.HashSet)

Example 9 with CapabilityStatementRestResourceComponent

use of org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareRestResourceInteractions.

private void compareRestResourceInteractions(StructuralMatch<Element> combined, CapabilityStatementRestResourceComponent left, CapabilityStatementRestResourceComponent right, String path, CapabilityStatementComparison res, CapabilityStatementRestResourceComponent union, CapabilityStatementRestResourceComponent intersection) {
    List<ResourceInteractionComponent> matchR = new ArrayList<>();
    for (ResourceInteractionComponent l : left.getInteraction()) {
        ResourceInteractionComponent r = findInList(right.getInteraction(), l);
        if (r == null) {
            union.getInteraction().add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
        } else {
            matchR.add(r);
            ResourceInteractionComponent cdM = mergeRestResourceInteractions(l, r);
            ResourceInteractionComponent cdI = intersectRestResourceInteractions(l, r);
            union.getInteraction().add(cdM);
            intersection.getInteraction().add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compareStrings(path, sm.getMessages(), l.getDocumentation(), r.getDocumentation(), "documentation", IssueSeverity.INFORMATION, res);
            compareExpectations(sm, l, r, path, res, union, intersection);
            combined.getChildren().add(sm);
        }
    }
    for (ResourceInteractionComponent r : right.getInteraction()) {
        if (!matchR.contains(r)) {
            union.getInteraction().add(r);
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), r));
        }
    }
}
Also used : ResourceInteractionComponent(org.hl7.fhir.r5.model.CapabilityStatement.ResourceInteractionComponent) BackboneElement(org.hl7.fhir.r5.model.BackboneElement) Element(org.hl7.fhir.r5.model.Element) ArrayList(java.util.ArrayList)

Example 10 with CapabilityStatementRestResourceComponent

use of org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method intersectRestResource.

private CapabilityStatementRestResourceComponent intersectRestResource(CapabilityStatementRestResourceComponent l, CapabilityStatementRestResourceComponent r) {
    CapabilityStatementRestResourceComponent res = new CapabilityStatementRestResourceComponent();
    res.setType(l.getType());
    // todo: compare profiles, not just copy
    if (l.hasProfile() && l.getProfile().equals(r.getProfile())) {
        res.setProfile(l.getProfile());
    }
    if (l.hasDocumentation() && l.getDocumentation().equals(r.getDocumentation())) {
        res.setDocumentation(l.getDocumentation());
    }
    return res;
}
Also used : CapabilityStatementRestResourceComponent(org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent)

Aggregations

CapabilityStatementRestResourceComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent)7 ArrayList (java.util.ArrayList)5 CapabilityStatementRestResourceComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent)4 CapabilityStatementRestResourceComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceComponent)4 CapabilityStatementRestComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 CapabilityStatementRestComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent)3 BackboneElement (org.hl7.fhir.r4b.model.BackboneElement)3 Element (org.hl7.fhir.r4b.model.Element)3 HashSet (java.util.HashSet)2 CapabilityStatementRestComponent (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent)2 CapabilityStatementRestResourceComponent (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent)2 CapabilityStatementRestResourceOperationComponent (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent)2 StringType (org.hl7.fhir.r4.model.StringType)2 BackboneElement (org.hl7.fhir.r5.model.BackboneElement)2 Element (org.hl7.fhir.r5.model.Element)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)2 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)1 VersionUtil (ca.uhn.fhir.util.VersionUtil)1