Search in sources :

Example 66 with SearchParameter

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

the class GraphQLSchemaGenerator method generateListAccess.

private void generateListAccess(BufferedWriter writer, List<SearchParameter> parameters, String name) throws IOException {
    writer.write("type " + name + "ListType {\r\n");
    writer.write("  " + name + "List(");
    param(writer, "_filter", "String", false, false);
    for (SearchParameter sp : parameters) param(writer, sp.getName().replace("-", "_"), getGqlname(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");
    writer.write("}\r\n");
    writer.write("\r\n");
}
Also used : SearchParameter(org.hl7.fhir.r4b.model.SearchParameter)

Example 67 with SearchParameter

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

the class GraphQLSchemaGenerator method generateConnectionAccessQuery.

public void generateConnectionAccessQuery(Writer writer, List<SearchParameter> parameters, String name) throws IOException {
    writer.write(name + "Conection(");
    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 + "Connection\r\n");
}
Also used : SearchParameter(org.hl7.fhir.r5.model.SearchParameter)

Example 68 with SearchParameter

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

the class RdfParser method composeSearchParameterSearchParameterContactComponent.

protected void composeSearchParameterSearchParameterContactComponent(Complex parent, String parentType, String name, SearchParameter.SearchParameterContactComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "contact", name, element, index);
    if (element.hasNameElement())
        composeString(t, "SearchParameter", "name", element.getNameElement(), -1);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "SearchParameter", "telecom", element.getTelecom().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 69 with SearchParameter

use of org.hl7.fhir.r4.model.SearchParameter 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)

Example 70 with SearchParameter

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

the class RdfParser method composeSearchParameterSearchParameterComponentComponent.

protected void composeSearchParameterSearchParameterComponentComponent(Complex parent, String parentType, String name, SearchParameter.SearchParameterComponentComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "component", name, element, index);
    if (element.hasDefinitionElement())
        composeCanonical(t, "SearchParameter", "definition", element.getDefinitionElement(), -1);
    if (element.hasExpressionElement())
        composeString(t, "SearchParameter", "expression", element.getExpressionElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

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