use of org.hl7.fhir.utilities.graphql.StringValue in project org.hl7.fhir.core by hapifhir.
the class GraphDefinitionEngine method parseParams.
private void parseParams(List<Argument> params, String value, Resource res) {
boolean refed = false;
Map<String, List<String>> p = splitQuery(value);
for (String n : p.keySet()) {
for (String v : p.get(n)) {
if (v.equals("{ref}")) {
refed = true;
v = res.fhirType() + '/' + res.getId();
}
params.add(new Argument(n, new StringValue(v)));
}
}
check(refed, "no use of {ref} found");
}
use of org.hl7.fhir.utilities.graphql.StringValue in project org.hl7.fhir.core by hapifhir.
the class GraphQLEngine method processReverseReferenceList.
private void processReverseReferenceList(Resource source, Field field, ObjectValue target, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException {
if (services == null)
throw new EGraphQLException("Resource Referencing services not provided");
List<IBaseResource> list = new ArrayList<>();
List<Argument> params = new ArrayList<>();
Argument parg = null;
for (Argument a : field.getArguments()) if (!(a.getName().equals("_reference")))
params.add(a);
else if ((parg == null))
parg = a;
else
throw new EGraphQLException("Duplicate parameter _reference");
if (parg == null)
throw new EGraphQLException("Missing parameter _reference");
Argument arg = new Argument();
params.add(arg);
arg.setName(getSingleValue(parg));
arg.addValue(new StringValue(source.fhirType() + "/" + source.getIdPart()));
services.listResources(appInfo, field.getName().substring(0, field.getName().length() - 4), params, list);
arg = null;
ObjectValue obj = null;
List<Resource> vl = filterResources(field.argument("fhirpath"), list);
if (!vl.isEmpty()) {
arg = target.addField(field.getAlias() + suffix, listStatus(field, true));
for (Resource v : vl) {
obj = new ObjectValue();
arg.addValue(obj);
processObject(v, v, obj, field.getSelectionSet(), inheritedList, suffix);
}
}
}
use of org.hl7.fhir.utilities.graphql.StringValue in project org.hl7.fhir.core by hapifhir.
the class GraphQLEngine method processSearchFull.
private void processSearchFull(ObjectValue target, Field field, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException {
if (services == null)
throw new EGraphQLException("Resource Referencing services not provided");
List<Argument> params = new ArrayList<Argument>();
Argument carg = null;
for (Argument arg : field.getArguments()) if (arg.getName().equals("cursor"))
carg = arg;
else
params.add(arg);
if ((carg != null)) {
params.clear();
;
String[] parts = getSingleValue(carg).split(":");
params.add(new Argument("search-id", new StringValue(parts[0])));
params.add(new Argument("search-offset", new StringValue(parts[1])));
}
Bundle bnd = (Bundle) services.search(appInfo, field.getName().substring(0, field.getName().length() - 10), params);
SearchWrapper bndWrapper = new SearchWrapper(field.getName(), bnd);
Argument arg = target.addField(field.getAlias() + suffix, listStatus(field, false));
ObjectValue obj = new ObjectValue();
arg.addValue(obj);
processObject(null, bndWrapper, obj, field.getSelectionSet(), inheritedList, suffix);
}
use of org.hl7.fhir.utilities.graphql.StringValue in project org.hl7.fhir.core by hapifhir.
the class GraphQLEngine method processReverseReferenceSearch.
private void processReverseReferenceSearch(Resource source, Field field, ObjectValue target, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException {
if (services == null)
throw new EGraphQLException("Resource Referencing services not provided");
List<Argument> params = new ArrayList<Argument>();
Argument parg = null;
for (Argument a : field.getArguments()) if (!(a.getName().equals("_reference")))
params.add(a);
else if ((parg == null))
parg = a;
else
throw new EGraphQLException("Duplicate parameter _reference");
if (parg == null)
throw new EGraphQLException("Missing parameter _reference");
Argument arg = new Argument();
params.add(arg);
arg.setName(getSingleValue(parg));
arg.addValue(new StringValue(source.fhirType() + "/" + source.getId()));
Bundle bnd = (Bundle) services.search(appInfo, field.getName().substring(0, field.getName().length() - 10), params);
Base bndWrapper = new SearchWrapper(field.getName(), bnd);
arg = target.addField(field.getAlias() + suffix, listStatus(field, false));
ObjectValue obj = new ObjectValue();
arg.addValue(obj);
processObject(null, bndWrapper, obj, field.getSelectionSet(), inheritedList, suffix);
}
use of org.hl7.fhir.utilities.graphql.StringValue in project org.hl7.fhir.core by hapifhir.
the class GraphQLEngine method processPrimitive.
private void processPrimitive(Argument arg, Base value) {
String s = value.fhirType();
if (s.equals("integer") || s.equals("decimal") || s.equals("unsignedInt") || s.equals("positiveInt"))
arg.addValue(new NumberValue(value.primitiveValue()));
else if (s.equals("boolean"))
arg.addValue(new NameValue(value.primitiveValue()));
else
arg.addValue(new StringValue(value.primitiveValue()));
}
Aggregations