Changes to enable request delete of specific Code System version.

This commit is contained in:
ianmarshall 2020-08-25 12:45:53 -04:00
parent 796d2923e0
commit 5a0bce9155
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package ca.uhn.fhir.jpa.dao;
import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemDao;
import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemVersionDao;
import ca.uhn.fhir.jpa.entity.TermCodeSystem;
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
public class HapiFhirResourceDaoCodeSystemUtil {
static public void deleteCodeSystemEntities(ITermCodeSystemDao theCsDao, ITermCodeSystemVersionDao theCsvDao,
ITermDeferredStorageSvc theTermDeferredStorageSvc, String theCodeSystemUrl,
String theCodeSystemVersion) {
if (isNotBlank(theCodeSystemUrl)) {
TermCodeSystem persCs = theCsDao.findByCodeSystemUri(theCodeSystemUrl);
if (persCs != null) {
if (theCodeSystemVersion != null) {
TermCodeSystemVersion persCsVersion = theCsvDao.findByCodeSystemPidAndVersion(persCs.getPid(), theCodeSystemVersion);
theTermDeferredStorageSvc.deleteCodeSystemVersion(persCsVersion);
} else {
theTermDeferredStorageSvc.deleteCodeSystem(persCs);
}
}
}
}
}