Support use of contained value sets when slicing by value set
This commit is contained in:
parent
40facbdf28
commit
6f6cd81552
|
@ -234,6 +234,11 @@ public class FHIRPathEngine {
|
|||
public Base resolveReference(Object appContext, String url) throws FHIRException;
|
||||
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException;
|
||||
|
||||
/*
|
||||
* return the value set referenced by the url, which has been used in memberOf()
|
||||
*/
|
||||
public ValueSet resolveValueSet(Object appContext, String url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1159,10 +1164,10 @@ public class FHIRPathEngine {
|
|||
work = work2;
|
||||
else if (last.getOperation() == Operation.Is || last.getOperation() == Operation.As) {
|
||||
work2 = executeTypeName(context, focus, next, false);
|
||||
work = operate(work, last.getOperation(), work2);
|
||||
work = operate(context, work, last.getOperation(), work2);
|
||||
} else {
|
||||
work2 = execute(context, focus, next, true);
|
||||
work = operate(work, last.getOperation(), work2);
|
||||
work = operate(context, work, last.getOperation(), work2);
|
||||
// System.out.println("Result of {'"+last.toString()+" "+last.getOperation().toCode()+" "+next.toString()+"'}: "+focus.toString());
|
||||
}
|
||||
last = next;
|
||||
|
@ -1381,7 +1386,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
|
||||
private List<Base> operate(List<Base> left, Operation operation, List<Base> right) throws FHIRException {
|
||||
private List<Base> operate(ExecutionContext context, List<Base> left, Operation operation, List<Base> right) throws FHIRException {
|
||||
switch (operation) {
|
||||
case Equals: return opEquals(left, right);
|
||||
case Equivalent: return opEquivalent(left, right);
|
||||
|
@ -1393,7 +1398,7 @@ public class FHIRPathEngine {
|
|||
case GreaterOrEqual: return opGreaterOrEqual(left, right);
|
||||
case Union: return opUnion(left, right);
|
||||
case In: return opIn(left, right);
|
||||
case MemberOf: return opMemberOf(left, right);
|
||||
case MemberOf: return opMemberOf(context, left, right);
|
||||
case Contains: return opContains(left, right);
|
||||
case Or: return opOr(left, right);
|
||||
case And: return opAnd(left, right);
|
||||
|
@ -1865,9 +1870,9 @@ public class FHIRPathEngine {
|
|||
return new ArrayList<Base>();
|
||||
}
|
||||
|
||||
private List<Base> opMemberOf(List<Base> left, List<Base> right) throws FHIRException {
|
||||
private List<Base> opMemberOf(ExecutionContext context, List<Base> left, List<Base> right) throws FHIRException {
|
||||
boolean ans = false;
|
||||
ValueSet vs = worker.fetchResource(ValueSet.class, right.get(0).primitiveValue());
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, right.get(0).primitiveValue()) : worker.fetchResource(ValueSet.class, right.get(0).primitiveValue());
|
||||
if (vs != null) {
|
||||
for (Base l : left) {
|
||||
if (l.fhirType().equals("code")) {
|
||||
|
@ -4305,5 +4310,10 @@ public class FHIRPathEngine {
|
|||
public TerminologyServiceOptions getTerminologyServiceOptions() {
|
||||
return terminologyServiceOptions;
|
||||
}
|
||||
|
||||
|
||||
public IWorkerContext getWorker() {
|
||||
return worker;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.hl7.fhir.r5.model.ExpressionNode;
|
|||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.Tuple;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.ExpressionNodeWithOffset;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
@ -417,4 +418,13 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
return conformsToProfile(ctxt.externalContext, item, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (externalHostServices != null)
|
||||
return externalHostServices.resolveValueSet(ctxt.externalContext, url);
|
||||
else
|
||||
return engine.getWorker().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -216,6 +216,11 @@ public class StructureMapUtilities {
|
|||
}
|
||||
throw new NotImplementedException("Not done yet (FFHIRPathHostServices.conformsToProfile), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
}
|
||||
private IWorkerContext worker;
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.hl7.fhir.r5.model.PrimitiveType;
|
|||
import org.hl7.fhir.r5.model.Quantity;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
|
@ -90,6 +91,11 @@ public class FHIRPathTests {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
return TestingUtilities.context().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static FHIRPathEngine fp;
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.hl7.fhir.r5.model.TestScript.TestScriptTestComponent;
|
|||
import org.hl7.fhir.r5.test.SnapShotGenerationTests.TestFetchMode;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.CodingUtilities;
|
||||
import org.hl7.fhir.r5.utils.EOperationOutcome;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
|
@ -351,6 +352,11 @@ public class SnapShotGenerationTests {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static FHIRPathEngine fp;
|
||||
|
|
Loading…
Reference in New Issue