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;
}
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());
}
}
}
}
}
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");
}
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++;
}
}
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"));
}
Aggregations