Permalink
Browse files

New drugs #21

  • Loading branch information...
mwl committed Sep 13, 2012
1 parent 6fcdeb0 commit a260c0a112f8edc10d4ec360bbae1e18b2081f6e
@@ -6,8 +6,6 @@
import java.util.List;
public interface DrugRepository extends GraphRepository<Drug> {
- Drug getByDrugId(String drugId);
-
List<Drug> findByNameLike(String name);
}
@@ -8,23 +8,12 @@
@NodeEntity
public class Drug extends NodeObject {
- @Indexed
- private String drugId;
-
@Indexed(indexType = IndexType.FULLTEXT, indexName = "DrugFull", fieldName = "name")
private String name;
@Fetch
private Concept refersTo;
- public String getDrugId() {
- return drugId;
- }
-
- public void setDrugId(String drugId) {
- this.drugId = drugId;
- }
-
public String getName() {
return name;
}
@@ -1,46 +0,0 @@
-package dk.sst.snomedcave.dao;
-
-import dk.sst.snomedcave.model.Drug;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.log4j.Logger;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.data.neo4j.support.Neo4jTemplate;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.inject.Inject;
-
-import java.util.List;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.hasItem;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "classpath:Neo4jConfig.xml")
-@Transactional
-public class DrugRepositoryTest {
-
- @SuppressWarnings("SpringJavaAutowiringInspection Provided by <neo4j:config .../> auto discovery")
- @Inject
- DrugRepository drugRepository;
-
- @Test
- public void canFindFlixonase() throws Exception {
- Drug drug = drugRepository.getByDrugId("28101368089");
- System.out.println("drug.getNodeId() = " + drug.getNodeId());
- assertNotNull(drug);
- assertEquals("Flixonase (FLUTICASONPROPIONAT)", drug.getName());
- assertNotNull(drug.getRefersTo());
- }
-
- @Test
- public void canFindDrugFromNamePart() throws Exception {
- List<Drug> drugs = drugRepository.findByNameLike("*xona*");
- assertFalse(drugs.isEmpty());
- assertThat(drugs, hasItem(equalTo(drugRepository.getByDrugId("28101368089"))));
- }
-}
@@ -208,7 +208,7 @@ public void importRelationships() {
}
public void importSubtances() {
- BeanReader in = getBeanReader("/data/ihs_lm_conceptid_dump.txt", "drugs");
+ BeanReader in = getBeanReader("/data/drugs.txt", "drugs");
Object record;
long startTime = currentTimeMillis();
@@ -223,9 +223,6 @@ public void importSubtances() {
final Map<String, Object> drug = (Map<String, Object>) record;
drug.put("__type__", "dk.sst.snomedcave.model.Drug");
- drug.put("name", String.format("%s (%s)", drug.get("drugName"), drug.get("substance")));
- drug.remove("drugName");
- drug.remove("substance");
final long conceptNodeId = getNodeId(drug.get("conceptId"));
drug.remove("conceptId");
@@ -236,7 +233,6 @@ public void importSubtances() {
drugIndex.add(nodeId, new HashMap<String, Object>() {{
put("__type__", "dk.sst.snomedcave.model.Drug");
- put("drugId", drug.get("drugId"));
}});
drugFullIndex.add(nodeId, new HashMap<String, Object>() {{
put("name", drug.get("name"));
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<beanio xmlns="http://www.beanio.org/2012/03">
+ <!--
+ substans conceptid
+ ^110^tin 8534003
+-->
<stream name="drugs" format="delimited">
<parser>
<property name="delimiter" value="\t"/>
</parser>
<!-- 'class' binds the header record to a java.util.HashMap -->
<record name="header" class="map">
- <field name="drugid" literal="drugid" rid="true"/>
- <field name="drugname" literal="drugname" rid="true"/>
- <field name="substans" literal="substans" rid="true"/>
- <field name="conceptid" literal="conceptid" rid="true"/>
+ <field name="Substans" literal="substans" rid="true"/>
+ <field name="Conceptid" literal="conceptid" rid="true"/>
</record>
<record name="drug" class="map">
- <field name="drugId"/>
- <field name="drugName"/>
- <field name="substance"/>
+ <field name="name"/>
<field name="conceptId"/>
</record>
</stream>
Oops, something went wrong.

0 comments on commit a260c0a

Please sign in to comment.