Search in sources :

Example 31 with SearchParameter

use of org.hl7.fhir.r4.model.SearchParameter in project org.hl7.fhir.core by hapifhir.

the class SearchParameterRenderer method render.

public boolean render(XhtmlNode x, SearchParameter spd) throws IOException, FHIRException, EOperationOutcome {
    x.h2().addText(spd.getName());
    XhtmlNode p = x.para();
    p.tx("Parameter ");
    p.code().tx(spd.getCode());
    p.tx(":");
    p.code().tx(spd.getType().toCode());
    addMarkdown(x, spd.getDescription());
    XhtmlNode tbl = x.table("grid");
    XhtmlNode tr = tbl.tr();
    tr.td().tx(Utilities.pluralize("Resource", spd.getBase().size()));
    XhtmlNode td = tr.td();
    for (CodeType t : spd.getBase()) {
        StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString());
        if (sd != null && sd.hasUserData("path")) {
            td.sep(", ").ah(sd.getUserString("path")).tx(t.getCode());
        } else {
            td.sep(", ").tx(t.getCode());
        }
    }
    tr = tbl.tr();
    tr.td().tx("Expression");
    if (spd.hasExpression()) {
        tr.td().code().tx(spd.getExpression());
    } else {
        tr.td().tx("(none)");
    }
    if (spd.hasXpathUsage()) {
        tr = tbl.tr();
        tr.td().tx("Usage");
        tr.td().tx(spd.getXpathUsage().getDisplay());
    }
    if (spd.hasXpath()) {
        tr = tbl.tr();
        tr.td().tx("XPath");
        tr.td().code().tx(spd.getXpath());
    }
    if (spd.hasTarget()) {
        tr = tbl.tr();
        tr.td().tx(Utilities.pluralize("Target Resources", spd.getTarget().size()));
        td = tr.td();
        for (CodeType t : spd.getTarget()) {
            StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString());
            if (sd != null && sd.hasUserData("path")) {
                td.sep(", ").ah(sd.getUserString("path")).tx(t.getCode());
            } else {
                td.sep(", ").tx(t.getCode());
            }
        }
    }
    tr = tbl.tr();
    tr.td().tx("Multiples");
    if (spd.getMultipleAnd() && spd.getMultipleOr()) {
        tr.td().tx("The parameter can repeat (and) and can have repeating values (or)");
    } else if (spd.getMultipleOr()) {
        tr.td().tx("The parameter can repeat (and) but each repeat can only have one value");
    } else if (spd.getMultipleAnd()) {
        tr.td().tx("The parameter cannot repeat (and) but the single parameter can have multiple values (or)");
    } else {
        tr.td().tx("The parameter cannot repeat or have multiple values");
    }
    if (spd.hasComparator()) {
        tr = tbl.tr();
        tr.td().tx("Comparators");
        td = tr.td().tx("Allowed: ");
        for (Enumeration<SearchComparator> t : spd.getComparator()) {
            td.sep(", ").tx(t.asStringValue());
        }
    }
    if (spd.hasModifier()) {
        tr = tbl.tr();
        tr.td().tx("Modifiers");
        td = tr.td().tx("Allowed: ");
        for (Enumeration<SearchModifierCode> t : spd.getModifier()) {
            td.sep(", ").tx(t.asStringValue());
        }
    }
    if (spd.hasChain()) {
        tr = tbl.tr();
        tr.td().tx("Chains");
        td = tr.td().tx("Allowed: ");
        for (StringType t : spd.getChain()) {
            td.sep(", ").tx(t.asStringValue());
        }
    }
    if (spd.hasComponent()) {
        x.para().b().tx("Components");
        tbl = x.table("grid");
        for (SearchParameterComponentComponent t : spd.getComponent()) {
            tr = tbl.tr();
            SearchParameter tsp = context.getWorker().fetchResource(SearchParameter.class, t.getDefinition());
            if (tsp != null && tsp.hasUserData("path")) {
                tr.td().ah(tsp.getUserString("path")).tx(tsp.present());
            } else {
                tr.td().tx(t.getDefinition());
            }
            tr.td().code().tx(t.getExpression());
        }
    }
    return false;
}
Also used : StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) StringType(org.hl7.fhir.r4b.model.StringType) SearchModifierCode(org.hl7.fhir.r4b.model.SearchParameter.SearchModifierCode) CodeType(org.hl7.fhir.r4b.model.CodeType) SearchComparator(org.hl7.fhir.r4b.model.SearchParameter.SearchComparator) SearchParameter(org.hl7.fhir.r4b.model.SearchParameter) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) SearchParameterComponentComponent(org.hl7.fhir.r4b.model.SearchParameter.SearchParameterComponentComponent)

Example 32 with SearchParameter

use of org.hl7.fhir.r4.model.SearchParameter in project org.hl7.fhir.core by hapifhir.

the class OpenApiGenerator method generateSearchSystem.

private void generateSearchSystem(CapabilityStatementRestComponent csr) {
    OperationWriter op = makePathSystem().operation("get");
    op.summary("Search all resources of all types based on a set of criteria");
    op.operationId("searchAll");
    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<>();
    set.add("_summary");
    set.add("_format");
    set.add("_pretty");
    set.add("_elements");
    for (CapabilityStatementRestResourceSearchParamComponent spc : csr.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)

Example 33 with SearchParameter

use of org.hl7.fhir.r4.model.SearchParameter in project org.hl7.fhir.core by hapifhir.

the class GraphQLSchemaGenerator method generateListAccessQuery.

public void generateListAccessQuery(Writer writer, List<SearchParameter> parameters, String name) throws IOException {
    writer.write(name + "List(");
    param(writer, "_filter", "String", false, false);
    for (SearchParameter sp : parameters) param(writer, sp.getName().replace("-", "_"), getGqlname(requireNonNull(sp.getType().toCode())), true, true);
    param(writer, "_sort", "String", false, true);
    param(writer, "_count", "Int", false, true);
    param(writer, "_cursor", "String", false, true);
    writer.write("): [" + name + "]\r\n");
}
Also used : SearchParameter(org.hl7.fhir.r5.model.SearchParameter)

Example 34 with SearchParameter

use of org.hl7.fhir.r4.model.SearchParameter in project org.hl7.fhir.core by hapifhir.

the class InstanceValidator method validateCapabilityStatement.

private void validateCapabilityStatement(List<ValidationMessage> errors, Element cs, NodeStack stack) {
    int iRest = 0;
    for (Element rest : cs.getChildrenByName("rest")) {
        int iResource = 0;
        for (Element resource : rest.getChildrenByName(RESOURCE)) {
            int iSP = 0;
            for (Element searchParam : resource.getChildrenByName("searchParam")) {
                String ref = searchParam.getChildValue("definition");
                String type = searchParam.getChildValue(TYPE);
                if (!Utilities.noString(ref)) {
                    SearchParameter sp = context.fetchResource(SearchParameter.class, ref);
                    if (sp != null) {
                        rule(errors, IssueType.INVALID, searchParam.line(), searchParam.col(), stack.getLiteralPath() + ".rest[" + iRest + "].resource[" + iResource + "].searchParam[" + iSP + "]", sp.getType().toCode().equals(type), I18nConstants.CAPABALITYSTATEMENT_CS_SP_WRONGTYPE, sp.getUrl(), sp.getType().toCode(), type);
                    }
                }
                iSP++;
            }
            iResource++;
        }
        iRest++;
    }
}
Also used : NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement) IndexedElement(org.hl7.fhir.validation.instance.utils.IndexedElement) SpecialElement(org.hl7.fhir.r5.elementmodel.Element.SpecialElement) Element(org.hl7.fhir.r5.elementmodel.Element) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 35 with SearchParameter

use of org.hl7.fhir.r4.model.SearchParameter in project org.hl7.fhir.core by hapifhir.

the class TurtleTests method test_searchparameter_example.

@Test
public void test_searchparameter_example() throws FileNotFoundException, IOException, Exception {
    System.out.println("searchparameter-example.ttl");
    new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\searchparameter-example.ttl"));
}
Also used : Turtle(org.hl7.fhir.dstu3.utils.formats.Turtle) Test(org.junit.jupiter.api.Test)

Aggregations

SearchParameter (org.hl7.fhir.r5.model.SearchParameter)32 FHIRException (org.hl7.fhir.exceptions.FHIRException)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 ArrayList (java.util.ArrayList)12 File (java.io.File)9 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 SearchParameter (org.hl7.fhir.r4b.model.SearchParameter)9 CodeType (org.hl7.fhir.r5.model.CodeType)9 HashSet (java.util.HashSet)8 FileOutputStream (java.io.FileOutputStream)7 XmlParser (org.hl7.fhir.r5.formats.XmlParser)7 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)6 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 ImplementationGuide (org.hl7.fhir.r5.model.ImplementationGuide)6 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)6 ConstraintStructure (org.hl7.fhir.definitions.model.ConstraintStructure)5 Example (org.hl7.fhir.definitions.model.Example)5