Fix PatientIdPartitionInterceptor where patient ID has hashCode equal to Integer.MIN_VALUE. (#3275)
* Fix PatientIdPartitionInterceptor for case where patient ID has hashCode equal to Integer.MIN_VALUE * Fix PatientIdPartitionInterceptor for case where patient ID has hashCode equal to Integer.MIN_VALUE Co-authored-by: ianmarshall <ian@simpatico.ai>
This commit is contained in:
parent
c38fdc4c42
commit
095b959917
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 3275
|
||||
title: "In rare cases where patient ID String happened to have hashCode equal to Integer.MIN_VALUE,
|
||||
PatientIdPartitionInterceptor would generate an invalid partition ID. This has been fixed."
|
|
@ -236,7 +236,7 @@ public class PatientIdPartitionInterceptor {
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected int providePartitionIdForPatientId(RequestDetails theRequestDetails, String theResourceIdPart) {
|
||||
return Math.abs(theResourceIdPart.hashCode()) % 15000;
|
||||
return Math.abs(theResourceIdPart.hashCode() % 15000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,6 +91,23 @@ public class PatientIdPartitionInterceptorTest extends BaseJpaR4SystemTest {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an edge case where a client assigned ID has a Java hashCode equal to Integer.MIN_VALUE.
|
||||
*/
|
||||
@Test
|
||||
public void testCreatePatient_polygenelubricants() {
|
||||
Patient patient = new Patient();
|
||||
patient.setId("Patient/polygenelubricants");
|
||||
patient.setActive(true);
|
||||
DaoMethodOutcome update = myPatientDao.update(patient);
|
||||
|
||||
runInTransaction(() -> {
|
||||
ResourceTable pt = myResourceTableDao.findAll().iterator().next();
|
||||
assertEquals("polygenelubricants", pt.getIdDt().getIdPart());
|
||||
assertEquals(8648, pt.getPartitionId().getPartitionId());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePatient_NonClientAssignedId() {
|
||||
Patient patient = new Patient();
|
||||
|
|
Loading…
Reference in New Issue