Search in sources :

Example 16 with StringValue

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>();
    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);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource)

Aggregations

StringValue (org.hl7.fhir.utilities.graphql.StringValue)12 Argument (org.hl7.fhir.utilities.graphql.Argument)10 ArrayList (java.util.ArrayList)8 EGraphQLException (org.hl7.fhir.utilities.graphql.EGraphQLException)8 ObjectValue (org.hl7.fhir.utilities.graphql.ObjectValue)8 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)4 List (java.util.List)3 LinkedList (java.util.LinkedList)2 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 Base (org.hl7.fhir.r4b.model.Base)2 Bundle (org.hl7.fhir.r4b.model.Bundle)2 Directive (org.hl7.fhir.utilities.graphql.Directive)2 NameValue (org.hl7.fhir.utilities.graphql.NameValue)2 NumberValue (org.hl7.fhir.utilities.graphql.NumberValue)2 CodeInfo (au.csiro.redmatch.terminology.CodeInfo)1 IObservation (ch.elexis.core.findings.IObservation)1 TransientCoding (ch.elexis.core.findings.util.model.TransientCoding)1 JsonElement (com.google.gson.JsonElement)1 Field (java.lang.reflect.Field)1 Matcher (java.util.regex.Matcher)1