JPA server was not correctly validating and expanding SCT codes

This commit is contained in:
James Agnew 2017-01-19 17:37:43 -05:00
parent 64e3435a8e
commit d1542e98c5
9 changed files with 39 additions and 11 deletions

View File

@ -74,7 +74,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
protected IFhirResourceDao<CarePlan> myCarePlanDao; protected IFhirResourceDao<CarePlan> myCarePlanDao;
@Autowired @Autowired
@Qualifier("myCodeSystemDaoDstu3") @Qualifier("myCodeSystemDaoDstu3")
protected IFhirResourceDao<CodeSystem> myCodeSystemDao; protected IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> myCodeSystemDao;
@Autowired @Autowired
@Qualifier("myCompartmentDefinitionDaoDstu3") @Qualifier("myCompartmentDefinitionDaoDstu3")
protected IFhirResourceDao<CompartmentDefinition> myCompartmentDefinitionDao; protected IFhirResourceDao<CompartmentDefinition> myCompartmentDefinitionDao;

View File

@ -11,15 +11,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.hl7.fhir.dstu3.model.AllergyIntolerance; import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory; import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory;
import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus; import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus;
import org.hl7.fhir.dstu3.model.AuditEvent;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode; import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.Observation;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.ValueSet.FilterOperator; import org.hl7.fhir.dstu3.model.ValueSet.FilterOperator;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent; import org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent;
@ -32,6 +28,7 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoCodeSystem.LookupCodeResult;
import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.jpa.entity.ResourceTable; import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
@ -159,6 +156,28 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
} }
} }
@Test
public void testLookupSnomed() {
CodeSystem codeSystem = new CodeSystem();
codeSystem.setUrl("http://snomed.info/sct");
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
TermCodeSystemVersion cs = new TermCodeSystemVersion();
cs.setResource(table);
cs.setResourceVersionId(table.getVersion());
TermConcept parentA = new TermConcept(cs, "ParentA").setDisplay("Parent A");
cs.getConcepts().add(parentA);
myTermSvc.storeNewCodeSystemVersion(table.getId(), "http://snomed.info/sct", cs);
StringType code = new StringType("ParentA");
StringType system = new StringType("http://snomed.info/sct");
LookupCodeResult outcome = myCodeSystemDao.lookupCode(code, system, null, mySrd);
assertEquals(true, outcome.isFound());
}
@Test @Test
public void testCodeSystemWithDefinedCodes() { public void testCodeSystemWithDefinedCodes() {
//@formatter:off //@formatter:off

View File

@ -0,0 +1,8 @@
package ca.uhn.fhirtest.config;
import org.springframework.context.annotation.Configuration;
@Configuration
public class DbServerConfig {
}

View File

@ -68,7 +68,6 @@ public class TdlDstu2Config extends BaseJavaConfigDstu2 {
} }
@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
// retVal.setDriver(new org.apache.derby.jdbc.ClientDriver()); // retVal.setDriver(new org.apache.derby.jdbc.ClientDriver());

View File

@ -65,7 +65,6 @@ public class TdlDstu3Config extends BaseJavaConfigDstu3 {
} }
@Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
// retVal.setDriver(new org.apache.derby.jdbc.ClientDriver()); // retVal.setDriver(new org.apache.derby.jdbc.ClientDriver());

View File

@ -70,7 +70,6 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
} }
@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.postgresql.Driver()); retVal.setDriver(new org.postgresql.Driver());

View File

@ -74,7 +74,6 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
} }
@Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.postgresql.Driver()); retVal.setDriver(new org.postgresql.Driver());

View File

@ -10,6 +10,7 @@ import org.apache.commons.io.Charsets;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent; import org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent;
@ -142,7 +143,7 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
@Override @Override
public boolean isCodeSystemSupported(FhirContext theContext, String theSystem) { public boolean isCodeSystemSupported(FhirContext theContext, String theSystem) {
CodeSystem cs = fetchCodeSystem(theContext, theSystem); CodeSystem cs = fetchCodeSystem(theContext, theSystem);
return cs != null; return cs != null && cs.getContent() != CodeSystemContentMode.NOTPRESENT;
} }
private void loadCodeSystems(FhirContext theContext, Map<String, CodeSystem> theCodeSystems, Map<String, ValueSet> theValueSets, String theClasspath) { private void loadCodeSystems(FhirContext theContext, Map<String, CodeSystem> theCodeSystems, Map<String, ValueSet> theValueSets, String theClasspath) {

View File

@ -213,6 +213,10 @@
Server AuthorizationInterceptor always rejects history operation Server AuthorizationInterceptor always rejects history operation
at the type level even if rules should allow it. at the type level even if rules should allow it.
</action> </action>
<action type="fix">
JPA server terminology service was not correctly validating or expanding codes
in SNOMED CT or LOINC code systems. Thanks to David Hay for reporting!
</action>
</release> </release>
<release version="2.1" date="2016-11-11"> <release version="2.1" date="2016-11-11">
<action type="add"> <action type="add">