001package org.hl7.fhir.r5.testfactory;
002
003import java.util.ArrayList;
004import java.util.List;
005
006import org.apache.commons.lang3.NotImplementedException;
007import org.hl7.fhir.exceptions.FHIRException;
008import org.hl7.fhir.exceptions.PathEngineException;
009import org.hl7.fhir.r5.context.SimpleWorkerContext;
010import org.hl7.fhir.r5.fhirpath.BaseHostServices;
011import org.hl7.fhir.r5.fhirpath.ExpressionNode.CollectionStatus;
012import org.hl7.fhir.r5.fhirpath.FHIRPathEngine;
013import org.hl7.fhir.r5.fhirpath.TypeDetails;
014import org.hl7.fhir.r5.liquid.GlobalObject;
015import org.hl7.fhir.r5.model.*;
016import org.hl7.fhir.utilities.MarkedToMoveToAdjunctPackage;
017import org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode;
018
019@MarkedToMoveToAdjunctPackage
020public class TestDataHostServices extends BaseHostServices {
021
022  private DateTimeType dt;
023  private DateType dtD;
024  private StringType pathToSpec;
025  
026  public TestDataHostServices(SimpleWorkerContext context, DateTimeType dt, DateType dtD, StringType pathToSpec) {
027    super(context);
028    this.dt = dt;
029    this.dtD = dtD;
030    this.pathToSpec = pathToSpec;
031  }
032
033  
034  @Override
035  public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode) throws PathEngineException {
036    if ("Globals".equals(name)) {
037      List<Base> list = new ArrayList<Base>();
038      list.add(new GlobalObject(dt, dtD, pathToSpec));
039      return list;
040    } else {
041      return new ArrayList<>();
042    }
043  }
044
045  @Override
046  public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode) throws PathEngineException {
047    if ("Globals".equals(name)) {
048      return new TypeDetails(CollectionStatus.SINGLETON, "GlobalObject");
049    } else {
050      return null; // whatever it is, we don't know about it.
051    }
052  }
053
054  @Override
055  public boolean paramIsType(String name, int index) {
056    return false;
057  }
058  
059  @Override
060  public boolean log(String argument, List<Base> focus) {
061    return false;
062  }
063
064  @Override
065  public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) {
066    return null;
067  }
068
069  @Override
070  public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
071    throw new NotImplementedException("Not done yet (TestDataHostServices.conformsToProfile)");
072  }
073
074  @Override
075  public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
076    throw new NotImplementedException("Not done yet (TestDataHostServices.resolveValueSet)"); // cause I don't know when we 'd need to do this
077  }
078
079  public Base findContainingResource(Object appContext, Base item) {
080    return null;
081  }
082}