validate-code operation now works with client-assigned IDs; added a bunch of failing tests to work on tomorrow.
This commit is contained in:
parent
5650bc9baa
commit
e67a750c4f
|
@ -47,8 +47,8 @@ public interface ITermValueSetConceptDao extends JpaRepository<TermValueSetConce
|
|||
Optional<TermValueSetConcept> findByTermValueSetIdSystemAndCode(@Param("pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSet.myResourcePid = :resource_pid AND vsc.myCode = :codeval")
|
||||
List<TermValueSetConcept> findOneByValueSetIdAndCode(@Param("resource_pid") Long theValueSetId, @Param("codeval") String theCode);
|
||||
List<TermValueSetConcept> findByValueSetResourcePidAndCode(@Param("resource_pid") Long theValueSetId, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSet.myResourcePid = :resource_pid AND vsc.mySystem = :system_url AND vsc.myCode = :codeval")
|
||||
List<TermValueSetConcept> findOneByValueSetIdSystemAndCode(@Param("resource_pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("codeval") String theCode);
|
||||
Optional<TermValueSetConcept> findByValueSetResourcePidSystemAndCode(@Param("resource_pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("codeval") String theCode);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
@Autowired
|
||||
private PlatformTransactionManager myTransactionMgr;
|
||||
private IFhirResourceDaoCodeSystem<?, ?, ?> myCodeSystemResourceDao;
|
||||
private IFhirResourceDaoValueSet<?, ?, ?> myValueSetResourceDao;
|
||||
private Cache<TranslationQuery, List<TermConceptMapGroupElementTarget>> myTranslationCache;
|
||||
private Cache<TranslationQuery, List<TermConceptMapGroupElement>> myTranslationWithReverseCache;
|
||||
private int myFetchSize = DEFAULT_FETCH_SIZE;
|
||||
|
@ -964,24 +965,24 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
ValueSet theValueSet, String theSystem, String theCode, String theDisplay, Coding theCoding, CodeableConcept theCodeableConcept) {
|
||||
|
||||
ValidateUtil.isNotNullOrThrowUnprocessableEntity(theValueSet.hasId(), "ValueSet.id is required");
|
||||
|
||||
Long valueSetId = theValueSet.getIdElement().toUnqualifiedVersionless().getIdPartAsLong();
|
||||
ResourceTable resource = (ResourceTable) myValueSetResourceDao.readEntity(theValueSet.getIdElement(), null);
|
||||
Long resourcePid = resource.getId();
|
||||
|
||||
List<TermValueSetConcept> concepts = new ArrayList<>();
|
||||
if (isNotBlank(theCode)) {
|
||||
if (isNotBlank(theSystem)) {
|
||||
concepts = myValueSetConceptDao.findOneByValueSetIdSystemAndCode(valueSetId, theSystem, theCode);
|
||||
concepts.addAll(findByValueSetResourcePidSystemAndCode(resourcePid, theSystem, theCode));
|
||||
} else {
|
||||
concepts = myValueSetConceptDao.findOneByValueSetIdAndCode(valueSetId, theCode);
|
||||
concepts.addAll(myValueSetConceptDao.findByValueSetResourcePidAndCode(resourcePid, theCode));
|
||||
}
|
||||
} else if (theCoding != null) {
|
||||
if (theCoding.hasSystem() && theCoding.hasCode()) {
|
||||
concepts = myValueSetConceptDao.findOneByValueSetIdSystemAndCode(valueSetId, theCoding.getSystem(), theCoding.getCode());
|
||||
concepts.addAll(findByValueSetResourcePidSystemAndCode(resourcePid, theCoding.getSystem(), theCoding.getCode()));
|
||||
}
|
||||
} else if (theCodeableConcept != null){
|
||||
for (Coding coding : theCodeableConcept.getCoding()) {
|
||||
if (coding.hasSystem() && coding.hasCode()) {
|
||||
concepts = myValueSetConceptDao.findOneByValueSetIdSystemAndCode(valueSetId, coding.getSystem(), coding.getCode());
|
||||
concepts.addAll(findByValueSetResourcePidSystemAndCode(resourcePid, coding.getSystem(), coding.getCode()));
|
||||
if (!concepts.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
@ -1002,6 +1003,15 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
return null;
|
||||
}
|
||||
|
||||
private List<TermValueSetConcept> findByValueSetResourcePidSystemAndCode(Long theResourcePid, String theSystem, String theCode) {
|
||||
List<TermValueSetConcept> retVal = new ArrayList<>();
|
||||
Optional<TermValueSetConcept> optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCode(theResourcePid, theSystem, theCode);
|
||||
if (optionalTermValueSetConcept.isPresent()) {
|
||||
retVal.add(optionalTermValueSetConcept.get());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private void fetchChildren(TermConcept theConcept, Set<TermConcept> theSetToPopulate) {
|
||||
for (TermConceptParentChildLink nextChildLink : theConcept.getChildren()) {
|
||||
TermConcept nextChild = nextChildLink.getChild();
|
||||
|
@ -1467,6 +1477,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
@PostConstruct
|
||||
public void start() {
|
||||
myCodeSystemResourceDao = myApplicationContext.getBean(IFhirResourceDaoCodeSystem.class);
|
||||
myValueSetResourceDao = myApplicationContext.getBean(IFhirResourceDaoValueSet.class);
|
||||
myTxTemplate = new TransactionTemplate(myTransactionManager);
|
||||
}
|
||||
|
||||
|
|
|
@ -365,23 +365,17 @@ public class HapiTerminologySvcDstu3 extends BaseHapiTerminologySvcImpl implemen
|
|||
@Override
|
||||
public ValidateCodeResult validateCodeIsInPreExpandedValueSet(IBaseResource theValueSet, String theSystem, String theCode, String theDisplay, IBaseDatatype theCoding, IBaseDatatype theCodeableConcept) {
|
||||
ValueSet valueSet = (ValueSet) theValueSet;
|
||||
org.hl7.fhir.r4.model.ValueSet valueSetR4 = VersionConvertor_30_40.convertValueSet(valueSet);
|
||||
|
||||
Coding coding = (Coding) theCoding;
|
||||
CodeableConcept codeableConcept = (CodeableConcept) theCodeableConcept;
|
||||
|
||||
try {
|
||||
org.hl7.fhir.r4.model.ValueSet valueSetR4;
|
||||
valueSetR4 = VersionConvertor_30_40.convertValueSet(valueSet);
|
||||
|
||||
org.hl7.fhir.r4.model.Coding codingR4 = new org.hl7.fhir.r4.model.Coding(coding.getSystem(), coding.getCode(), coding.getDisplay());
|
||||
|
||||
CodeableConcept codeableConcept = (CodeableConcept) theCodeableConcept;
|
||||
org.hl7.fhir.r4.model.CodeableConcept codeableConceptR4 = new org.hl7.fhir.r4.model.CodeableConcept();
|
||||
for (Coding nestedCoding : codeableConcept.getCoding()) {
|
||||
codeableConceptR4.addCoding(new org.hl7.fhir.r4.model.Coding(nestedCoding.getSystem(), nestedCoding.getCode(), nestedCoding.getDisplay()));
|
||||
}
|
||||
|
||||
return super.validateCodeIsInPreExpandedValueSet(valueSetR4, theSystem, theCode, theDisplay, codingR4, codeableConceptR4);
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import ca.uhn.fhir.util.UrlUtil;
|
|||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r5.model.*;
|
||||
import org.hl7.fhir.r5.hapi.ctx.IValidationSupport;
|
||||
import org.hl7.fhir.r5.model.*;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander;
|
||||
|
@ -291,7 +291,8 @@ public class HapiTerminologySvcR5 extends BaseHapiTerminologySvcImpl implements
|
|||
|
||||
@Override
|
||||
public ValidateCodeResult validateCodeIsInPreExpandedValueSet(IBaseResource theValueSet, String theSystem, String theCode, String theDisplay, IBaseDatatype theCoding, IBaseDatatype theCodeableConcept) {
|
||||
org.hl7.fhir.r4.model.ValueSet valueSetR4 = org.hl7.fhir.convertors.conv40_50.ValueSet.convertValueSet((ValueSet) theValueSet);
|
||||
ValueSet valueSet = (ValueSet) theValueSet;
|
||||
org.hl7.fhir.r4.model.ValueSet valueSetR4 = org.hl7.fhir.convertors.conv40_50.ValueSet.convertValueSet(valueSet);
|
||||
|
||||
Coding coding = (Coding) theCoding;
|
||||
org.hl7.fhir.r4.model.Coding codingR4 = new org.hl7.fhir.r4.model.Coding(coding.getSystem(), coding.getCode(), coding.getDisplay());
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue