wip
This commit is contained in:
parent
606b642b1e
commit
f6d44fe50c
|
@ -239,7 +239,7 @@ public class EmpiLinkDaoSvc {
|
||||||
|
|
||||||
private List<Long> deleteEmpiLinksAndReturnPersonPids(List<EmpiLink> theLinks) {
|
private List<Long> deleteEmpiLinksAndReturnPersonPids(List<EmpiLink> theLinks) {
|
||||||
List<Long> collect = theLinks.stream().map(EmpiLink::getPersonPid).distinct().collect(Collectors.toList());
|
List<Long> collect = theLinks.stream().map(EmpiLink::getPersonPid).distinct().collect(Collectors.toList());
|
||||||
theLinks.forEach(empiLink -> myEmpiLinkDao.delete(empiLink));
|
myEmpiLinkDao.deleteAll(theLinks);
|
||||||
return collect;
|
return collect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||||
import ca.uhn.fhir.jpa.api.model.DeleteConflict;
|
import ca.uhn.fhir.jpa.api.model.DeleteConflict;
|
||||||
import ca.uhn.fhir.jpa.api.model.DeleteConflictList;
|
import ca.uhn.fhir.jpa.api.model.DeleteConflictList;
|
||||||
import ca.uhn.fhir.jpa.dao.expunge.IResourceExpungeService;
|
import ca.uhn.fhir.jpa.dao.expunge.IResourceExpungeService;
|
||||||
import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService;
|
|
||||||
import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
|
import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
@ -37,7 +36,10 @@ import org.hl7.fhir.r4.model.IdType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@ -55,7 +57,9 @@ public class EmpiResetSvcImpl implements IEmpiResetSvc {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DaoRegistry myDaoRegistry;
|
private DaoRegistry myDaoRegistry;
|
||||||
@Autowired
|
@Autowired
|
||||||
private HapiTransactionService myTransactionService;
|
private PlatformTransactionManager myTransactionManager;
|
||||||
|
|
||||||
|
private TransactionTemplate myTxTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long expungeAllEmpiLinksOfTargetType(String theResourceType) {
|
public long expungeAllEmpiLinksOfTargetType(String theResourceType) {
|
||||||
|
@ -74,14 +78,14 @@ public class EmpiResetSvcImpl implements IEmpiResetSvc {
|
||||||
private void deleteResourcesAndHandleConflicts(List<Long> theLongs) {
|
private void deleteResourcesAndHandleConflicts(List<Long> theLongs) {
|
||||||
DeleteConflictList
|
DeleteConflictList
|
||||||
deleteConflictList = new DeleteConflictList();
|
deleteConflictList = new DeleteConflictList();
|
||||||
myTransactionService.execute(null, tx -> {
|
myTxTemplate.execute(tx -> {
|
||||||
theLongs.stream().forEach(pid -> deleteCascade(pid, deleteConflictList));
|
theLongs.stream().forEach(pid -> deleteCascade(pid, deleteConflictList));
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
IFhirResourceDao personDao = myDaoRegistry.getResourceDao("Person");
|
IFhirResourceDao personDao = myDaoRegistry.getResourceDao("Person");
|
||||||
while (!deleteConflictList.isEmpty()) {
|
while (!deleteConflictList.isEmpty()) {
|
||||||
myTransactionService.execute(null, tx -> {
|
myTxTemplate.execute(tx -> {
|
||||||
deleteConflictBatch(deleteConflictList, personDao);
|
deleteConflictBatch(deleteConflictList, personDao);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -95,6 +99,12 @@ public class EmpiResetSvcImpl implements IEmpiResetSvc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void start() {
|
||||||
|
myTxTemplate = new TransactionTemplate(myTransactionManager);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO GGG this operation likely won't scale very well. Consider adding slicing
|
* TODO GGG this operation likely won't scale very well. Consider adding slicing
|
||||||
*/
|
*/
|
||||||
|
@ -128,7 +138,8 @@ public class EmpiResetSvcImpl implements IEmpiResetSvc {
|
||||||
private void deleteCascade(Long pid, DeleteConflictList theDeleteConflictList) {
|
private void deleteCascade(Long pid, DeleteConflictList theDeleteConflictList) {
|
||||||
ourLog.debug("About to cascade delete: " + pid);
|
ourLog.debug("About to cascade delete: " + pid);
|
||||||
IFhirResourceDao resourceDao = myDaoRegistry.getResourceDao("Person");
|
IFhirResourceDao resourceDao = myDaoRegistry.getResourceDao("Person");
|
||||||
resourceDao.delete(new IdType("Person/" + pid), theDeleteConflictList, null, null);
|
myTxTemplate.executeWithoutResult((tx) -> resourceDao.delete(new IdType("Person/" + pid), theDeleteConflictList, null, null));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,17 +50,17 @@ public class EmpiProviderLoader {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IResourceLoader myResourceLoader;
|
private IResourceLoader myResourceLoader;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IEmpiResetSvc myEmpiExpungeSvc;
|
private IEmpiResetSvc myEmpiResetSvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IEmpiBatchService myEmpiBatchSvc;
|
private IEmpiBatchService myEmpiBatchSvc;
|
||||||
|
|
||||||
public void loadProvider() {
|
public void loadProvider() {
|
||||||
switch (myFhirContext.getVersion().getVersion()) {
|
switch (myFhirContext.getVersion().getVersion()) {
|
||||||
case DSTU3:
|
case DSTU3:
|
||||||
myResourceProviderFactory.addSupplier(() -> new EmpiProviderDstu3(myFhirContext, myEmpiMatchFinderSvc, myPersonMergerSvc, myEmpiLinkUpdaterSvc, myEmpiLinkQuerySvc, myResourceLoader, myEmpiExpungeSvc, myEmpiBatchSvc));
|
myResourceProviderFactory.addSupplier(() -> new EmpiProviderDstu3(myFhirContext, myEmpiMatchFinderSvc, myPersonMergerSvc, myEmpiLinkUpdaterSvc, myEmpiLinkQuerySvc, myResourceLoader, myEmpiResetSvc, myEmpiBatchSvc));
|
||||||
break;
|
break;
|
||||||
case R4:
|
case R4:
|
||||||
myResourceProviderFactory.addSupplier(() -> new EmpiProviderR4(myFhirContext, myEmpiMatchFinderSvc, myPersonMergerSvc, myEmpiLinkUpdaterSvc, myEmpiLinkQuerySvc, myResourceLoader, myEmpiExpungeSvc, myEmpiBatchSvc));
|
myResourceProviderFactory.addSupplier(() -> new EmpiProviderR4(myFhirContext, myEmpiMatchFinderSvc, myPersonMergerSvc, myEmpiLinkUpdaterSvc, myEmpiLinkQuerySvc, myResourceLoader, myEmpiResetSvc, myEmpiBatchSvc));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ConfigurationException("EMPI not supported for FHIR version " + myFhirContext.getVersion().getVersion());
|
throw new ConfigurationException("EMPI not supported for FHIR version " + myFhirContext.getVersion().getVersion());
|
||||||
|
|
Loading…
Reference in New Issue