Remove resourceType, version, and qualifier from FHIRPath id results (#1357)

* Breaking test

* Strip returned IIdType of qualifier, version, and resourceType

* Add fix to r4b

* Add fix to r5
This commit is contained in:
dotasek 2023-07-22 11:01:13 -04:00 committed by GitHub
parent b73111adf6
commit b62f9afc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 5 deletions

View File

@ -451,12 +451,19 @@ public class FHIRPathEngine {
if (list != null) { if (list != null) {
for (Base v : list) { for (Base v : list) {
if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) { 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() { public boolean isLegacyMode() {
return legacyMode; return legacyMode;

View File

@ -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<Base> results = fp.evaluate(input, "Patient.id");
assertEquals(1, results.size());
assertEquals("123", results.get(0).toString());
}
} }

View File

@ -447,13 +447,20 @@ public class FHIRPathEngine {
if (list != null) { if (list != null) {
for (Base v : list) { for (Base v : list) {
if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) { 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() { public boolean isLegacyMode() {
return legacyMode; return legacyMode;
} }

View File

@ -295,4 +295,13 @@ public class FHIRPathTests {
assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue()); assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue());
assertEquals(DUMMY_CONSTANT_2, result.get(1).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<Base> results = fp.evaluate(input, "Patient.id");
assertEquals(1, results.size());
assertEquals("123", results.get(0).toString());
}
} }

View File

@ -457,13 +457,18 @@ public class FHIRPathEngine {
if (list != null) { if (list != null) {
for (Base v : list) { for (Base v : list) {
if (v != null && (tn == null || v.fhirType().equalsIgnoreCase(tn))) { 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() { public boolean isLegacyMode() {
return legacyMode; return legacyMode;
} }

View File

@ -301,4 +301,13 @@ public class FHIRPathTests {
assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue()); assertEquals(DUMMY_CONSTANT_1, result.get(0).primitiveValue());
assertEquals(DUMMY_CONSTANT_2, result.get(1).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<Base> results = fp.evaluate(input, "Patient.id");
assertEquals(1, results.size());
assertEquals("123", results.get(0).toString());
}
} }