diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java index ac95b18d29d..88d74058923 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java @@ -74,7 +74,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { protected IFhirResourceDao myCarePlanDao; @Autowired @Qualifier("myCodeSystemDaoDstu3") - protected IFhirResourceDao myCodeSystemDao; + protected IFhirResourceDaoCodeSystem myCodeSystemDao; @Autowired @Qualifier("myCompartmentDefinitionDaoDstu3") protected IFhirResourceDao myCompartmentDefinitionDao; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java index 0fa7c375d2c..2efb85d863e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java @@ -11,15 +11,11 @@ import java.util.ArrayList; import java.util.List; 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.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.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.FilterOperator; import org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent; @@ -32,6 +28,7 @@ import org.junit.Ignore; import org.junit.Test; 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.entity.ResourceTable; 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 public void testCodeSystemWithDefinedCodes() { //@formatter:off diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/DbServerConfig.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/DbServerConfig.java new file mode 100644 index 00000000000..b670e9a2cd7 --- /dev/null +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/DbServerConfig.java @@ -0,0 +1,8 @@ +package ca.uhn.fhirtest.config; + +import org.springframework.context.annotation.Configuration; + +@Configuration +public class DbServerConfig { + +} diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu2Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu2Config.java index e9054df5094..51ffedf1a03 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu2Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu2Config.java @@ -68,7 +68,6 @@ public class TdlDstu2Config extends BaseJavaConfigDstu2 { } @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") - @DependsOn("dbServer") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); // retVal.setDriver(new org.apache.derby.jdbc.ClientDriver()); diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu3Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu3Config.java index 55c36fd991c..04155e821a9 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu3Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TdlDstu3Config.java @@ -65,7 +65,6 @@ public class TdlDstu3Config extends BaseJavaConfigDstu3 { } @Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close") - @DependsOn("dbServer") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); // retVal.setDriver(new org.apache.derby.jdbc.ClientDriver()); diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java index 43f5207dbec..cb8997c90aa 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java @@ -70,7 +70,6 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 { } @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") - @DependsOn("dbServer") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); retVal.setDriver(new org.postgresql.Driver()); diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java index 193d356f687..065cbe50e43 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java @@ -74,7 +74,6 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { } @Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close") - @DependsOn("dbServer") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); retVal.setDriver(new org.postgresql.Driver()); diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/validation/DefaultProfileValidationSupport.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/validation/DefaultProfileValidationSupport.java index 7e03a606668..fb5cf9a36bb 100644 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/validation/DefaultProfileValidationSupport.java +++ b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/validation/DefaultProfileValidationSupport.java @@ -10,6 +10,7 @@ import org.apache.commons.io.Charsets; import org.apache.commons.lang3.Validate; import org.hl7.fhir.dstu3.model.*; 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.OperationOutcome.IssueSeverity; import org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent; @@ -142,7 +143,7 @@ public class DefaultProfileValidationSupport implements IValidationSupport { @Override public boolean isCodeSystemSupported(FhirContext theContext, String theSystem) { CodeSystem cs = fetchCodeSystem(theContext, theSystem); - return cs != null; + return cs != null && cs.getContent() != CodeSystemContentMode.NOTPRESENT; } private void loadCodeSystems(FhirContext theContext, Map theCodeSystems, Map theValueSets, String theClasspath) { diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f547a5486a2..213489b85f5 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -213,6 +213,10 @@ Server AuthorizationInterceptor always rejects history operation at the type level even if rules should allow it. + + JPA server terminology service was not correctly validating or expanding codes + in SNOMED CT or LOINC code systems. Thanks to David Hay for reporting! +