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 ace7041d3..a5f43da2e 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 @@ -22,6 +22,7 @@ import org.fhir.ucum.UcumException; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.conformance.ProfileUtilities; import org.hl7.fhir.r4.context.IWorkerContext; import org.hl7.fhir.r4.context.IWorkerContext.ValidationResult; @@ -894,7 +895,9 @@ public class FHIRPathEngine { } public String convertToString(Base item) { - if (item.isPrimitive()) { + if (item instanceof IIdType) { + return ((IIdType)item).getIdPart(); + } else if (item.isPrimitive()) { return item.primitiveValue(); } else if (item instanceof Quantity) { Quantity q = (Quantity) item; 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 b0b065f60..5a803584d 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 @@ -295,4 +295,16 @@ public class FHIRPathTests { assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue()); assertEquals(DUMMY_CONSTANT_2, result.get(1).primitiveValue()); } + + + @Test + public void testEvaluateToString_Id() { + Patient input = new Patient(); + input.setId(new IdType("http://base/Patient/123/_history/222")); + String actual = fp.evaluateToString(input, "Patient.id"); + assertEquals("123", actual); + + } + + } \ 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 1ec7ed7ca..15d82473c 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 @@ -22,6 +22,7 @@ import org.fhir.ucum.UcumException; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4b.conformance.ProfileUtilities; import org.hl7.fhir.r4b.context.IWorkerContext; import org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult; @@ -890,7 +891,9 @@ public class FHIRPathEngine { } public String convertToString(Base item) { - if (item.isPrimitive()) { + if (item instanceof IIdType) { + return ((IIdType)item).getIdPart(); + } else if (item.isPrimitive()) { return item.primitiveValue(); } else if (item instanceof Quantity) { Quantity q = (Quantity) item; 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 cd27d44ce..3e6797757 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 @@ -22,6 +22,7 @@ import org.fhir.ucum.UcumException; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r5.conformance.profile.ProfileUtilities; import org.hl7.fhir.r5.conformance.profile.ProfileUtilities.SourcedChildDefinitions; import org.hl7.fhir.r5.context.ContextUtilities; @@ -952,7 +953,9 @@ public class FHIRPathEngine { } public String convertToString(Base item) { - if (item.isPrimitive()) { + if (item instanceof IIdType) { + return ((IIdType)item).getIdPart(); + } else if (item.isPrimitive()) { return item.primitiveValue(); } else if (item instanceof Quantity) { Quantity q = (Quantity) item;