Search in sources :

Example 11 with CapabilityStatementRestResourceSearchParamComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compareSearchParams.

private void compareSearchParams(StructuralMatch<Element> combined, List<CapabilityStatementRestResourceSearchParamComponent> left, List<CapabilityStatementRestResourceSearchParamComponent> right, String path, CapabilityStatementComparison res, List<CapabilityStatementRestResourceSearchParamComponent> union, List<CapabilityStatementRestResourceSearchParamComponent> intersection) {
    List<CapabilityStatementRestResourceSearchParamComponent> matchR = new ArrayList<>();
    for (CapabilityStatementRestResourceSearchParamComponent l : left) {
        CapabilityStatementRestResourceSearchParamComponent r = findInList(right, l);
        if (r == null) {
            union.add(l);
            combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this Search Parameter", path)));
        } else {
            matchR.add(r);
            CapabilityStatementRestResourceSearchParamComponent cdM = mergeSearchParams(l, r);
            CapabilityStatementRestResourceSearchParamComponent cdI = intersectSearchParams(l, r);
            union.add(cdM);
            intersection.add(cdI);
            StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
            compareStrings(path, sm.getMessages(), l.getDocumentation(), r.getDocumentation(), "documentation", IssueSeverity.INFORMATION, res);
            compareItemProperty(sm, "type", l.getTypeElement(), r.getTypeElement(), path, res, cdM.getTypeElement(), cdI.getTypeElement(), IssueSeverity.ERROR);
            compareItemProperty(sm, "definition", l.getDefinitionElement(), r.getDefinitionElement(), path, res, cdM.getDefinitionElement(), cdI.getDefinitionElement(), IssueSeverity.ERROR);
            compareExpectations(sm, l, r, path, res, cdM, cdI);
            combined.getChildren().add(sm);
        }
    }
    for (CapabilityStatementRestResourceSearchParamComponent r : right) {
        if (!matchR.contains(r)) {
            union.add(r);
            combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this Search Parameter", path), r));
        }
    }
}
Also used : BackboneElement(org.hl7.fhir.r4b.model.BackboneElement) Element(org.hl7.fhir.r4b.model.Element) ArrayList(java.util.ArrayList) CapabilityStatementRestResourceSearchParamComponent(org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent)

Example 12 with CapabilityStatementRestResourceSearchParamComponent

use of org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent 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.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) HashSet(java.util.HashSet)

Aggregations

CapabilityStatementRestResourceSearchParamComponent (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent)7 CapabilityStatementRestResourceSearchParamComponent (org.hl7.fhir.r4b.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent)5 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)2 SearchParameter (org.hl7.fhir.r4b.model.SearchParameter)2 SearchParameter (org.hl7.fhir.r5.model.SearchParameter)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)2 XPathQueryGenerator (org.hl7.fhir.definitions.generators.specification.XPathQueryGenerator)1 BackboneElement (org.hl7.fhir.r4b.model.BackboneElement)1 Element (org.hl7.fhir.r4b.model.Element)1 BackboneElement (org.hl7.fhir.r5.model.BackboneElement)1 Element (org.hl7.fhir.r5.model.Element)1