Fix #8- Can't read version history of resource with non-numeric ID

This commit is contained in:
James Agnew 2014-08-08 14:16:40 -04:00
parent b43b6c6d2f
commit cbd79d66ad
2 changed files with 24 additions and 1 deletions

View File

@ -357,7 +357,7 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
if (entity == null) {
if (theId.hasVersionIdPart()) {
TypedQuery<ResourceHistoryTable> q = myEntityManager.createQuery("SELECT t from ResourceHistoryTable t WHERE t.myResourceId = :RID AND t.myResourceType = :RTYP AND t.myResourceVersion = :RVER", ResourceHistoryTable.class);
q.setParameter("RID", theId.getIdPartAsLong());
q.setParameter("RID", pid);
q.setParameter("RTYP", myResourceName);
q.setParameter("RVER", theId.getVersionIdPartAsLong());
entity = q.getSingleResult();

View File

@ -1386,6 +1386,29 @@ public class FhirResourceDaoTest {
}
@Test
public void testReadForcedIdVersionHistory() throws InterruptedException {
Patient p1 = new Patient();
p1.addIdentifier("urn:system", "testReadVorcedIdVersionHistory01");
p1.setId("testReadVorcedIdVersionHistory");
IdDt p1id = ourPatientDao.create(p1).getId();
assertEquals("testReadVorcedIdVersionHistory", p1id.getIdPart());
p1.addIdentifier("urn:system", "testReadVorcedIdVersionHistory02");
IdDt p1idv2 = ourPatientDao.update(p1, p1id).getId();
assertEquals("testReadVorcedIdVersionHistory", p1idv2.getIdPart());
assertNotEquals(p1id.getValue(), p1idv2.getValue());
Patient v1 = ourPatientDao.read(p1id);
assertEquals(1, v1.getIdentifier().size());
Patient v2 = ourPatientDao.read(p1idv2);
assertEquals(2, v2.getIdentifier().size());
}
@SuppressWarnings("unchecked")
private <T extends IResource> List<T> toList(IBundleProvider theSearch) {
return (List<T>) theSearch.getResources(0, theSearch.size());