From 149f7caad26f9c7d853ded767950d0f0545f0437 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 27 Jan 2020 21:11:33 +1100 Subject: [PATCH] fixes in memberOf and add source to resolve() interface --- .../java/org/hl7/fhir/r5/utils/FHIRPathEngine.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index 3c5d9fbe7..5581e0c32 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -232,7 +232,7 @@ public class FHIRPathEngine { * @return * @throws FHIRException */ - public Base resolveReference(Object appContext, String url) throws FHIRException; + public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException; public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException; @@ -1887,7 +1887,7 @@ public class FHIRPathEngine { 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")) { + if (Utilities.existsInList(l.fhirType(), "code", "string", "uri")) { if (worker.validateCode(terminologyServiceOptions , TypeConvertor.castToCoding(l), vs).isOk()) ans = true; } else if (l.fhirType().equals("Coding")) { @@ -1896,6 +1896,8 @@ public class FHIRPathEngine { } else if (l.fhirType().equals("CodeableConcept")) { if (worker.validateCode(terminologyServiceOptions, TypeConvertor.castToCodeableConcept(l), vs).isOk()) ans = true; + } else { +// System.out.println("unknown type in opMemberOf: "+l.fhirType()); } } } @@ -2870,13 +2872,14 @@ public class FHIRPathEngine { return new ArrayList(); } Base l = focus.get(0); - if (l.fhirType().equals("code")) { + if (Utilities.existsInList(l.fhirType(), "code", "string", "uri")) { return makeBoolean(worker.validateCode(terminologyServiceOptions.guessSystem(), TypeConvertor.castToCoding(l), vs).isOk()); } else if (l.fhirType().equals("Coding")) { return makeBoolean(worker.validateCode(terminologyServiceOptions, TypeConvertor.castToCoding(l), vs).isOk()); } else if (l.fhirType().equals("CodeableConcept")) { return makeBoolean(worker.validateCode(terminologyServiceOptions, TypeConvertor.castToCodeableConcept(l), vs).isOk()); } else { +// System.out.println("unknown type in funcMemberOf: "+l.fhirType()); return new ArrayList(); } } @@ -3312,9 +3315,11 @@ public class FHIRPathEngine { private List funcResolve(ExecutionContext context, List focus, ExpressionNode exp) throws FHIRException { List result = new ArrayList(); + Base refContext = null; for (Base item : focus) { String s = convertToString(item); if (item.fhirType().equals("Reference")) { + refContext = item; Property p = item.getChildByName("reference"); if (p != null && p.hasValues()) s = convertToString(p.getValues().get(0)); @@ -3323,6 +3328,7 @@ public class FHIRPathEngine { } if (item.fhirType().equals("canonical")) { s = item.primitiveValue(); + refContext = item; } if (s != null) { Base res = null; @@ -3335,7 +3341,7 @@ public class FHIRPathEngine { } } } else if (hostServices != null) { - res = hostServices.resolveReference(context.appInfo, s); + res = hostServices.resolveReference(context.appInfo, s, refContext); } if (res != null) result.add(res);