Fixed duplicate ConceptMap URL only
This commit is contained in:
parent
45b88de3b6
commit
1ecec0abc9
|
@ -142,6 +142,7 @@ ca.uhn.fhir.jpa.binstore.BinaryAccessProvider.unknownType=Content in resource of
|
||||||
|
|
||||||
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateCodeSystemUrl=Can not create multiple CodeSystem resources with CodeSystem.url "{0}", already have one with resource ID: {1}
|
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateCodeSystemUrl=Can not create multiple CodeSystem resources with CodeSystem.url "{0}", already have one with resource ID: {1}
|
||||||
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateConceptMapUrl=Can not create multiple ConceptMap resources with ConceptMap.url "{0}", already have one with resource ID: {1}
|
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateConceptMapUrl=Can not create multiple ConceptMap resources with ConceptMap.url "{0}", already have one with resource ID: {1}
|
||||||
|
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateConceptMapUrlAndVersion=Can not create multiple ConceptMap resources with ConceptMap.url "{0}", ConceptMap.version "{1}", already have one with resource ID: {2}
|
||||||
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateValueSetUrl=Can not create multiple ValueSet resources with ValueSet.url "{0}", already have one with resource ID: {1}
|
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateValueSetUrl=Can not create multiple ValueSet resources with ValueSet.url "{0}", already have one with resource ID: {1}
|
||||||
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.expansionTooLarge=Expansion of ValueSet produced too many codes (maximum {0}) - Operation aborted!
|
ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.expansionTooLarge=Expansion of ValueSet produced too many codes (maximum {0}) - Operation aborted!
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,7 @@ public interface ITermConceptMapDao extends JpaRepository<TermConceptMap, Long>
|
||||||
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myResourcePid = :resource_pid")
|
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myResourcePid = :resource_pid")
|
||||||
Optional<TermConceptMap> findTermConceptMapByResourcePid(@Param("resource_pid") Long theResourcePid);
|
Optional<TermConceptMap> findTermConceptMapByResourcePid(@Param("resource_pid") Long theResourcePid);
|
||||||
|
|
||||||
//-- Replaced with next method. Should it be removed?
|
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url and cm.myVersion is null")
|
||||||
@Deprecated
|
|
||||||
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url")
|
|
||||||
Optional<TermConceptMap> findTermConceptMapByUrl(@Param("url") String theUrl);
|
Optional<TermConceptMap> findTermConceptMapByUrl(@Param("url") String theUrl);
|
||||||
|
|
||||||
@Query(value="SELECT cm FROM TermConceptMap cm INNER JOIN ResourceTable r ON r.myId = cm.myResourcePid WHERE cm.myUrl = :url ORDER BY r.myUpdated DESC")
|
@Query(value="SELECT cm FROM TermConceptMap cm INNER JOIN ResourceTable r ON r.myId = cm.myResourcePid WHERE cm.myUrl = :url ORDER BY r.myUpdated DESC")
|
||||||
|
|
|
@ -1550,7 +1550,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
*/
|
*/
|
||||||
String conceptMapUrl = termConceptMap.getUrl();
|
String conceptMapUrl = termConceptMap.getUrl();
|
||||||
String conceptMapVersion = termConceptMap.getVersion();
|
String conceptMapVersion = termConceptMap.getVersion();
|
||||||
Optional<TermConceptMap> optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrlAndVersion(conceptMapUrl, conceptMapVersion);
|
Optional<TermConceptMap> optionalExistingTermConceptMapByUrl = null;
|
||||||
|
if (isBlank(conceptMapVersion)) {
|
||||||
|
optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrl(conceptMapUrl);
|
||||||
|
} else {
|
||||||
|
optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrlAndVersion(conceptMapUrl, conceptMapVersion);
|
||||||
|
}
|
||||||
if (!optionalExistingTermConceptMapByUrl.isPresent()) {
|
if (!optionalExistingTermConceptMapByUrl.isPresent()) {
|
||||||
try {
|
try {
|
||||||
if (isNotBlank(source)) {
|
if (isNotBlank(source)) {
|
||||||
|
@ -1631,13 +1636,22 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
} else {
|
} else {
|
||||||
TermConceptMap existingTermConceptMap = optionalExistingTermConceptMapByUrl.get();
|
TermConceptMap existingTermConceptMap = optionalExistingTermConceptMapByUrl.get();
|
||||||
|
|
||||||
String msg = myContext.getLocalizer().getMessage(
|
if (isBlank(conceptMapVersion)) {
|
||||||
BaseTermReadSvcImpl.class,
|
String msg = myContext.getLocalizer().getMessage(
|
||||||
"cannotCreateDuplicateConceptMapUrlAndVersion",
|
BaseTermReadSvcImpl.class,
|
||||||
conceptMapUrl, conceptMapVersion,
|
"cannotCreateDuplicateConceptMapUrl",
|
||||||
existingTermConceptMap.getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
conceptMapUrl,
|
||||||
|
existingTermConceptMap.getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||||
throw new UnprocessableEntityException(msg);
|
throw new UnprocessableEntityException(msg);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String msg = myContext.getLocalizer().getMessage(
|
||||||
|
BaseTermReadSvcImpl.class,
|
||||||
|
"cannotCreateDuplicateConceptMapUrlAndVersion",
|
||||||
|
conceptMapUrl, conceptMapVersion,
|
||||||
|
existingTermConceptMap.getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||||
|
throw new UnprocessableEntityException(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ourLog.info("Done storing TermConceptMap[{}] for {}", termConceptMap.getId(), theConceptMap.getIdElement().toVersionless().getValueAsString());
|
ourLog.info("Done storing TermConceptMap[{}] for {}", termConceptMap.getId(), theConceptMap.getIdElement().toVersionless().getValueAsString());
|
||||||
|
@ -1949,6 +1963,14 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
predicates.add(criteriaBuilder.equal(groupJoin.get("myTarget"), translationQuery.getTargetSystem().getValueAsString()));
|
predicates.add(criteriaBuilder.equal(groupJoin.get("myTarget"), translationQuery.getTargetSystem().getValueAsString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (translationQuery.hasUrl()) {
|
||||||
|
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl().getValueAsString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (translationQuery.hasConceptMapVersion()) {
|
||||||
|
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVerion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||||
|
}
|
||||||
|
|
||||||
if (translationQuery.hasSource()) {
|
if (translationQuery.hasSource()) {
|
||||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("mySource"), translationQuery.getSource().getValueAsString()));
|
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("mySource"), translationQuery.getSource().getValueAsString()));
|
||||||
}
|
}
|
||||||
|
@ -2032,6 +2054,14 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
predicates.add(criteriaBuilder.equal(groupJoin.get("myTargetVersion"), coding.getVersion()));
|
predicates.add(criteriaBuilder.equal(groupJoin.get("myTargetVersion"), coding.getVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (translationQuery.hasUrl()) {
|
||||||
|
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl().getValueAsString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (translationQuery.hasConceptMapVersion()) {
|
||||||
|
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVerion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||||
|
}
|
||||||
|
|
||||||
if (translationQuery.hasTargetSystem()) {
|
if (translationQuery.hasTargetSystem()) {
|
||||||
predicates.add(criteriaBuilder.equal(groupJoin.get("mySource"), translationQuery.getTargetSystem().getValueAsString()));
|
predicates.add(criteriaBuilder.equal(groupJoin.get("mySource"), translationQuery.getTargetSystem().getValueAsString()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue