diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java
index 8eaf15d47..cea94921d 100644
--- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java
+++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/FHIRPathEngine.java
@@ -451,12 +451,19 @@ public class FHIRPathEngine {
if (list != null) {
for (Base v : list) {
if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) {
- result.add(v);
+ result.add(filterIdType(v));
}
}
}
}
+ private Base filterIdType(Base v) {
+ if (v instanceof IIdType) {
+ return (Base) ((IIdType) v).toUnqualifiedVersionless().withResourceType(null);
+ }
+ return v;
+ }
+
public boolean isLegacyMode() {
return legacyMode;
diff --git a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRPathTests.java b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRPathTests.java
index 5a803584d..53b377140 100644
--- a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRPathTests.java
+++ b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRPathTests.java
@@ -306,5 +306,12 @@ public class FHIRPathTests {
}
-
+ @Test
+ public void testEvaluate_Id() {
+ Patient input = new Patient();
+ input.setId(new IdType("http://base/Patient/123/_history/222"));
+ List results = fp.evaluate(input, "Patient.id");
+ assertEquals(1, results.size());
+ assertEquals("123", results.get(0).toString());
+ }
}
\ No newline at end of file
diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/FHIRPathEngine.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/FHIRPathEngine.java
index 603636448..f59de7f48 100644
--- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/FHIRPathEngine.java
+++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/FHIRPathEngine.java
@@ -447,13 +447,20 @@ public class FHIRPathEngine {
if (list != null) {
for (Base v : list) {
if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) {
- result.add(v);
+ result.add(filterIdType(v));
}
}
}
}
+ private Base filterIdType(Base v) {
+ if (v instanceof IIdType) {
+ return (Base) ((IIdType) v).toUnqualifiedVersionless().withResourceType(null);
+ }
+ return v;
+ }
+
public boolean isLegacyMode() {
return legacyMode;
}
diff --git a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/FHIRPathTests.java b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/FHIRPathTests.java
index df02ac436..3f1e3a5db 100644
--- a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/FHIRPathTests.java
+++ b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/FHIRPathTests.java
@@ -295,4 +295,13 @@ public class FHIRPathTests {
assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue());
assertEquals(DUMMY_CONSTANT_2, result.get(1).primitiveValue());
}
+
+ @Test
+ public void testEvaluate_Id() {
+ Patient input = new Patient();
+ input.setId(new IdType("http://base/Patient/123/_history/222"));
+ List results = fp.evaluate(input, "Patient.id");
+ assertEquals(1, results.size());
+ assertEquals("123", results.get(0).toString());
+ }
}
\ No newline at end of file
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 1422ea1b3..657bd6c1f 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
@@ -457,13 +457,18 @@ public class FHIRPathEngine {
if (list != null) {
for (Base v : list) {
if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) {
- result.add(v);
+ result.add(filterIdType(v));
}
}
}
}
-
+ private Base filterIdType(Base v) {
+ if (v instanceof IIdType) {
+ return (Base) ((IIdType) v).toUnqualifiedVersionless().withResourceType(null);
+ }
+ return v;
+ }
public boolean isLegacyMode() {
return legacyMode;
}
diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java
index f27aab1c7..d803ae08d 100644
--- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java
+++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java
@@ -301,4 +301,13 @@ public class FHIRPathTests {
assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue());
assertEquals(DUMMY_CONSTANT_2, result.get(1).primitiveValue());
}
+
+ @Test
+ public void testEvaluate_Id() {
+ Patient input = new Patient();
+ input.setId(new IdType("http://base/Patient/123/_history/222"));
+ List results = fp.evaluate(input, "Patient.id");
+ assertEquals(1, results.size());
+ assertEquals("123", results.get(0).toString());
+ }
}
\ No newline at end of file