Skip to content

Commit

Permalink
Fixed parent and children counts (were zero)
Browse files Browse the repository at this point in the history
  • Loading branch information
schuemie committed Nov 28, 2017
1 parent dcfd1c2 commit 7168404
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 15 additions & 7 deletions src/org/ohdsi/usagi/indexBuilding/BerkeleyDbBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ public void buildIndex(String vocabFolder, String loincFileName, BuildThread bui
this.buildThread = buildThread;
dbEngine = new BerkeleyDbEngine(Global.folder);
dbEngine.createDatabase();
IntHashSet validConceptIds = loadConcepts(vocabFolder + "/CONCEPT.csv", loincFileName);
IntHashSet validConceptIds = loadValidConceptIds(vocabFolder + "/CONCEPT.csv");
loadAncestors(vocabFolder + "/CONCEPT_ANCESTOR.csv", validConceptIds);
loadRelationships(vocabFolder + "/CONCEPT_RELATIONSHIP.csv", validConceptIds);
loadConcepts(vocabFolder + "/CONCEPT.csv", loincFileName);
dbEngine.shutdown();
}

private IntHashSet loadValidConceptIds(String conceptFileName) {
IntHashSet validConceptIds = new IntHashSet();
for (Row row : new ReadAthenaFile(conceptFileName))
if (row.get("invalid_reason") == null)
validConceptIds.add(row.getInt("concept_id"));
return validConceptIds;
}

private void loadRelationships(String conceptRelationshipFileName, IntHashSet validConceptIds) {
buildThread.report("Loading relationship information");
int count = 0;
Expand Down Expand Up @@ -72,14 +81,14 @@ private void loadAncestors(String conceptAncestorFileName, IntHashSet validConce
}
}

private IntHashSet loadConcepts(String conceptFileName, String loincFileName) {
private void loadConcepts(String conceptFileName, String loincFileName) {
Map<String, String> loincToInfo = null;
if (loincFileName != null) {
buildThread.report("Loading LOINC additional information");
loincToInfo = loadLoincInfo(loincFileName);
}
buildThread.report("Loading concept information");
IntHashSet validConceptIds = new IntHashSet();
int count = 0;
for (Row row : new ReadAthenaFile(conceptFileName)) {
Concept concept = new Concept(row);
if (concept.invalidReason == null) {
Expand All @@ -91,12 +100,11 @@ private IntHashSet loadConcepts(String conceptFileName, String loincFileName) {
concept.parentCount = dbEngine.getParentChildRelationshipsByChildConceptId(concept.conceptId).size();
concept.childCount = dbEngine.getParentChildRelationshipsByParentConceptId(concept.conceptId).size();
dbEngine.put(concept);
validConceptIds.add(concept.conceptId);
if (validConceptIds.size() % 100000 == 0)
System.out.println("Loaded " + validConceptIds.size() + " concepts");
count++;
if (count % 100000 == 0)
System.out.println("Loaded " + count + " concepts");
}
}
return validConceptIds;
}

private Map<String, String> loadLoincInfo(String loincFile) {
Expand Down
4 changes: 1 addition & 3 deletions src/org/ohdsi/usagi/indexBuilding/LuceneIndexBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ public void buildIndex(String vocabFolder, String loincFile, BuildThread buildTh
count = 0;
for (Row row : new ReadAthenaFile(vocabFolder + "/CONCEPT_SYNONYM.csv")) {
Concept concept = dbEngine.getConcept(row.getInt("concept_id"));
if (concept == null) {
System.err.println("Concept not found for concept ID " + row.getInt("concept_id"));
} else {
if (concept != null) {
if ((concept.standardConcept.equals("S") || concept.standardConcept.equals("C"))
&& !concept.conceptName.toLowerCase().equals(row.get("concept_synonym_name").toLowerCase())) {
usagiSearchEngine.addTermToIndex(row.get("concept_synonym_name"), UsagiSearchEngine.CONCEPT_TERM, concept);
Expand Down

0 comments on commit 7168404

Please sign in to comment.