Missing fix from #3197

This commit is contained in:
jamesagnew 2021-11-30 16:15:09 -05:00
parent 0099749a27
commit 1a1243db34
2 changed files with 12 additions and 3 deletions

View File

@ -1826,8 +1826,14 @@ public abstract class BaseTransactionProcessor {
}
IIdType replacement = theIdSubstitutions.getForSource(paramValue);
if (replacement != null) {
matchUrl = matchUrl.substring(0, equalsIdx + 1) + replacement.getValue() + matchUrl.substring(endIdx);
searchFrom = equalsIdx + 1 + replacement.getValue().length();
String replacementValue;
if (replacement.hasVersionIdPart()) {
replacementValue = replacement.toVersionless().getValue();
} else {
replacementValue = replacement.getValue();
}
matchUrl = matchUrl.substring(0, equalsIdx + 1) + replacementValue + matchUrl.substring(endIdx);
searchFrom = equalsIdx + 1 + replacementValue.length();
} else {
searchFrom = endIdx;
}

View File

@ -16,10 +16,13 @@ public class BaseTransactionProcessorTest {
assertEquals("Patient?foo=Patient/123&bar=baz", outcome);
}
/**
* Make sure versioned targets get the version stripped
*/
@Test
void testPerformIdSubstitutionsInMatchUrl_MatchAtEnd() {
IdSubstitutionMap idSubstitutions = new IdSubstitutionMap();
idSubstitutions.put(new IdType("urn:uuid:7ea4f3a6-d2a3-4105-9f31-374d525085d4"), new IdType("Patient/123"));
idSubstitutions.put(new IdType("urn:uuid:7ea4f3a6-d2a3-4105-9f31-374d525085d4"), new IdType("Patient/123/_history/1"));
String outcome = BaseTransactionProcessor.performIdSubstitutionsInMatchUrl(idSubstitutions, "Patient?name=FAMILY1&organization=urn%3Auuid%3A7ea4f3a6-d2a3-4105-9f31-374d525085d4");
assertEquals("Patient?name=FAMILY1&organization=Patient/123", outcome);
}