Fixed lookupCode implementation in InMemoryTerminologyServerValidationSupport.
This commit is contained in:
parent
4216cee8c6
commit
b32c4f01a8
|
@ -121,7 +121,12 @@ public class FhirResourceDaoCodeSystemDstu3 extends BaseHapiFhirResourceDao<Code
|
|||
|
||||
if (myValidationSupport.isCodeSystemSupported(new ValidationSupportContext(myValidationSupport), system)) {
|
||||
ourLog.debug("Code system {} is supported", system);
|
||||
IValidationSupport.LookupCodeResult result = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code, codeSystemVersion);
|
||||
IValidationSupport.LookupCodeResult result;
|
||||
if (codeSystemVersion != null) {
|
||||
result = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code, codeSystemVersion);
|
||||
} else {
|
||||
result = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code);
|
||||
}
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,12 @@ public class FhirResourceDaoCodeSystemR4 extends BaseHapiFhirResourceDao<CodeSys
|
|||
if (myValidationSupport.isCodeSystemSupported(new ValidationSupportContext(myValidationSupport), system)) {
|
||||
|
||||
ourLog.debug("Code system {} is supported", system);
|
||||
IValidationSupport.LookupCodeResult retVal = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code, codeSystemVersion);
|
||||
IValidationSupport.LookupCodeResult retVal;
|
||||
if (codeSystemVersion != null) {
|
||||
retVal = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code, codeSystemVersion);
|
||||
} else {
|
||||
retVal = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code);
|
||||
}
|
||||
if (retVal != null) {
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,12 @@ public class FhirResourceDaoCodeSystemR5 extends BaseHapiFhirResourceDao<CodeSys
|
|||
if (myValidationSupport.isCodeSystemSupported(new ValidationSupportContext(myValidationSupport), system)) {
|
||||
|
||||
ourLog.debug("Code system {} is supported", system);
|
||||
IValidationSupport.LookupCodeResult retVal = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code, codeSystemVersion);
|
||||
IValidationSupport.LookupCodeResult retVal;
|
||||
if (codeSystemVersion != null) {
|
||||
retVal = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code, codeSystemVersion);
|
||||
} else {
|
||||
retVal = myValidationSupport.lookupCode(new ValidationSupportContext(myValidationSupport), system, code);
|
||||
}
|
||||
if (retVal != null) {
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -310,8 +310,40 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
|
|||
|
||||
@Override
|
||||
public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theVersion) {
|
||||
// TODO: Add support for validating versioned codes as well.
|
||||
return lookupCode(theValidationSupportContext, theSystem, theCode);
|
||||
// The following code mostly duplicates the validateCode method, differing in that it includes the code system version in the generated ValueSet resource.
|
||||
IBaseResource vs;
|
||||
switch (myCtx.getVersion().getVersion()) {
|
||||
case DSTU3:
|
||||
vs = new org.hl7.fhir.dstu3.model.ValueSet()
|
||||
.setCompose(new org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent()
|
||||
.addInclude(new org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent().setSystem(theSystem).setVersion(theVersion)));
|
||||
break;
|
||||
case R4:
|
||||
vs = new org.hl7.fhir.r4.model.ValueSet()
|
||||
.setCompose(new org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent()
|
||||
.addInclude(new org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent().setSystem(theSystem).setVersion(theVersion)));
|
||||
break;
|
||||
case R5:
|
||||
vs = new org.hl7.fhir.r5.model.ValueSet()
|
||||
.setCompose(new org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent()
|
||||
.addInclude(new org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent().setSystem(theSystem).setVersion(theVersion)));
|
||||
break;
|
||||
case DSTU2_HL7ORG:
|
||||
case DSTU2:
|
||||
case DSTU2_1:
|
||||
default:
|
||||
throw new IllegalArgumentException("Can not handle version: " + myCtx.getVersion().getVersion());
|
||||
}
|
||||
|
||||
ValueSetExpansionOutcome valueSetExpansionOutcome = expandValueSet(theValidationSupportContext, null, vs);
|
||||
if (valueSetExpansionOutcome == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IBaseResource expansion = valueSetExpansionOutcome.getValueSet();
|
||||
|
||||
return validateCodeInExpandedValueSet(theValidationSupportContext, new ConceptValidationOptions(), theSystem, theCode, null, expansion).asLookupCodeResult(theSystem, theCode);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -476,7 +508,6 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
|
|||
|
||||
List<VersionIndependentConcept> nextCodeList = new ArrayList<>();
|
||||
String system = nextInclude.getSystem();
|
||||
String systemVersion = nextInclude.getVersion();
|
||||
if (isNotBlank(system)) {
|
||||
|
||||
if (theWantSystem != null && !theWantSystem.equals(system)) {
|
||||
|
@ -499,7 +530,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
|
|||
|
||||
if (theWantCode != null) {
|
||||
if (theValidationSupportContext.getRootValidationSupport().isCodeSystemSupported(theValidationSupportContext, system)) {
|
||||
LookupCodeResult lookup = theValidationSupportContext.getRootValidationSupport().lookupCode(theValidationSupportContext, system, theWantCode, systemVersion);
|
||||
LookupCodeResult lookup = theValidationSupportContext.getRootValidationSupport().lookupCode(theValidationSupportContext, system, theWantCode);
|
||||
if (lookup != null && lookup.isFound()) {
|
||||
CodeSystem.ConceptDefinitionComponent conceptDefinition = new CodeSystem.ConceptDefinitionComponent()
|
||||
.addConcept()
|
||||
|
|
Loading…
Reference in New Issue