Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/filter-status-0' into develop

  • Loading branch information...
commit 9382d8940e5f6737ac7ea0dd7bf3ff99c9738f00 2 parents a260c0a + 2166bd3
Martin Westergaard Lassen mwl authored
9 sc-web/src/main/java/dk/sst/snomedcave/controllers/DrugController.java
View
@@ -77,6 +77,11 @@
public boolean evaluate(ConceptRelation relation) {
if (conceptRepository.findOne(relation.getType().getNodeId()).getNodeId().equals(causativeAgentId())) {
Node childNode = neo4jTemplate.getNode(relation.getChild().getNodeId());
+ Concept child = conceptRepository.findOne(childNode.getId());
+ if (child.getStatus() != 0) {
+ logger.debug("Filtered out child with status=" + child.getStatus() + " for " + child.getTerm());
+ return false;
+ }
Traverser paths = td.traverse(childNode);
List<Path> pathList = IteratorUtils.toList(paths.iterator());
@@ -102,9 +107,7 @@ public boolean evaluate(ConceptRelation relation) {
concept = conceptRepository.findOne(causativesDrugAllergy.get(0).getChild().getNodeId());
- JsonObject response = new JsonObject();
- response.addProperty("allergyId", concept.getConceptId());
- return new ResponseEntity<String>(gson.toJson(response), HttpStatus.OK);
+ return new ResponseEntity<String>(concept.getConceptId(), HttpStatus.OK);
}
private long causativeAgentId() {
4 sc-web/src/main/webapp/js/application.js
View
@@ -109,8 +109,8 @@ module.directive("caveRegistration", function($http, $log) {
scope.findDrug = function(query) {
scope.allergyTree = undefined;
$log.info("Will lookup " + query)
- $http.get("/drugs/concepttree?name=" + query).success(function(drug, status) {
- getConcept(drug.allergyId)
+ $http.get("/drugs/concepttree?name=" + query).success(function(allergyId, status) {
+ getConcept(allergyId)
})
}
45 sc-web/src/test/java/dk/sst/snomedcave/controllers/DrugControllerTest.java
View
@@ -0,0 +1,45 @@
+package dk.sst.snomedcave.controllers;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.ImportResource;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = DrugControllerTest.TestConfig.class)
+@Transactional
+public class DrugControllerTest {
+ Gson gson = new GsonBuilder().create();
+
+ @Configuration
+ @ImportResource("classpath:/Neo4jConfig.xml")
+ public static class TestConfig {
+ @Bean
+ public DrugController drugController() {
+ return new DrugController();
+ }
+ }
+
+ @Inject
+ DrugController drugController;
+
+ @Test
+ public void willAlwaysReturnNonCombinedDrug() throws Exception {
+ for (int i = 0; i < 100; i++) {
+ String allergyId = drugController.tree("Paracetamol").getBody();
+ assertNotNull(allergyId);
+ assertEquals(i + " of 10", "293584003", allergyId);
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.