001package org.hl7.fhir.utilities.graphql;
002
003/*-
004 * #%L
005 * org.hl7.fhir.utilities
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import org.hl7.fhir.exceptions.FHIRException;
024import org.hl7.fhir.instance.model.api.IBaseBundle;
025import org.hl7.fhir.instance.model.api.IBaseReference;
026import org.hl7.fhir.instance.model.api.IBaseResource;
027
028import java.util.List;
029
030public interface IGraphQLStorageServices {
031
032  /**
033   * given a reference inside a context, return what it references (including resolving internal references (e.g. start with #)
034   */
035  ReferenceResolution lookup(Object appInfo, IBaseResource context, IBaseReference reference) throws FHIRException;
036
037  /**
038   * just get the identified resource
039   */
040  IBaseResource lookup(Object appInfo, String type, String id) throws FHIRException;
041
042  /**
043   * list the matching resources. searchParams are the standard search params.
044   * this instanceof different to search because the server returns all matching resources, or an error. There instanceof no paging on this search
045   */
046  void listResources(Object appInfo, String type, List<Argument> searchParams, List<IBaseResource> matches) throws FHIRException;
047
048  /**
049   * just perform a standard search, and return the bundle as you return to the client
050   */
051  IBaseBundle search(Object appInfo, String type, List<Argument> searchParams) throws FHIRException;
052
053  class ReferenceResolution {
054    private IBaseResource targetContext;
055    private IBaseResource target;
056
057    public ReferenceResolution(IBaseResource targetContext, IBaseResource target) {
058      super();
059      this.targetContext = targetContext;
060      this.target = target;
061    }
062
063    public IBaseResource getTargetContext() {
064      return targetContext;
065    }
066
067    public IBaseResource getTarget() {
068      return target;
069    }
070
071
072  }
073}