Skip to content

Commit

Permalink
JPA server was not correctly validating and expanding SCT codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Jan 19, 2017
1 parent 64e3435 commit d1542e9
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
protected IFhirResourceDao<CarePlan> myCarePlanDao;
@Autowired
@Qualifier("myCodeSystemDaoDstu3")
protected IFhirResourceDao<CodeSystem> myCodeSystemDao;
protected IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> myCodeSystemDao;
@Autowired
@Qualifier("myCompartmentDefinitionDaoDstu3")
protected IFhirResourceDao<CompartmentDefinition> myCompartmentDefinitionDao;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
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;
Expand All @@ -32,6 +28,7 @@
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;
Expand Down Expand Up @@ -159,6 +156,28 @@ public void testCodeSystemCreateDuplicateFails() {
}
}

@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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ca.uhn.fhirtest.config;

import org.springframework.context.annotation.Configuration;

@Configuration
public class DbServerConfig {

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public DaoConfig daoConfig() {
}

@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource();
// retVal.setDriver(new org.apache.derby.jdbc.ClientDriver());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public IServerInterceptor securityInterceptor() {
}

@Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource();
// retVal.setDriver(new org.apache.derby.jdbc.ClientDriver());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public DaoConfig daoConfig() {
}

@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.postgresql.Driver());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public IServerInterceptor securityInterceptor() {
}

@Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close")
@DependsOn("dbServer")
public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource();
retVal.setDriver(new org.postgresql.Driver());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand Down Expand Up @@ -142,7 +143,7 @@ public void flush() {
@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<String, CodeSystem> theCodeSystems, Map<String, ValueSet> theValueSets, String theClasspath) {
Expand Down
4 changes: 4 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@
Server AuthorizationInterceptor always rejects history operation
at the type level even if rules should allow it.
</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 version="2.1" date="2016-11-11">
<action type="add">
Expand Down

0 comments on commit d1542e9

Please sign in to comment.