Search in sources :

Example 11 with ReferenceResolution

use of org.hl7.fhir.utilities.graphql.IGraphQLStorageServices.ReferenceResolution in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngine method processCanonicalReference.

private void processCanonicalReference(Resource context, Base source, Field field, ObjectValue target, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException {
    if (!(source instanceof CanonicalType))
        throw new EGraphQLException("Not done yet");
    if (services == null)
        throw new EGraphQLException("Resource Referencing services not provided");
    Reference ref = new Reference(source.primitiveValue());
    ReferenceResolution res = services.lookup(appInfo, context, ref);
    if (res != null) {
        if (targetTypeOk(field.getArguments(), res.getTarget())) {
            Argument arg = target.addField(field.getAlias() + suffix, listStatus(field, inheritedList));
            ObjectValue obj = new ObjectValue();
            arg.addValue(obj);
            processObject((Resource) res.getTargetContext(), (Base) res.getTarget(), obj, field.getSelectionSet(), inheritedList, suffix);
        }
    } else if (!hasArgument(field.getArguments(), "optional", "true"))
        throw new EGraphQLException("Unable to resolve reference to " + ref.getReference());
}
Also used : ReferenceResolution(org.hl7.fhir.utilities.graphql.IGraphQLStorageServices.ReferenceResolution)

Aggregations

ReferenceResolution (org.hl7.fhir.utilities.graphql.IGraphQLStorageServices.ReferenceResolution)10 Argument (org.hl7.fhir.utilities.graphql.Argument)4 EGraphQLException (org.hl7.fhir.utilities.graphql.EGraphQLException)4 ObjectValue (org.hl7.fhir.utilities.graphql.ObjectValue)4 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)3 Reference (org.hl7.fhir.r4b.model.Reference)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 XmlParser (org.hl7.fhir.r4.formats.XmlParser)1 DomainResource (org.hl7.fhir.r4.model.DomainResource)1 Resource (org.hl7.fhir.r4.model.Resource)1 Base (org.hl7.fhir.r4b.model.Base)1 CanonicalType (org.hl7.fhir.r4b.model.CanonicalType)1 ExpressionNode (org.hl7.fhir.r4b.model.ExpressionNode)1 GraphDefinitionLinkComponent (org.hl7.fhir.r4b.model.GraphDefinition.GraphDefinitionLinkComponent)1 GraphDefinitionLinkTargetComponent (org.hl7.fhir.r4b.model.GraphDefinition.GraphDefinitionLinkTargetComponent)1