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