Created
September 18, 2014 23:20
-
-
Save palexander/68f4cecf433890c439b6 to your computer and use it in GitHub Desktop.
Find RXNORM ingredients and brand names then expand the labels across CUI mappings to NCI and SNOMEDCT_US
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/palexander/goumls" | |
import "log" | |
func main() { | |
// Filters for queries | |
rxnorm := toEntries("RXNORM") | |
rxnormTTY := toEntries("IN", "BN") | |
expandedTTY := toEntries("AB", "PT", "SY") | |
// Concepts | |
concepts := umlsdb.ConceptsAll(goumls.Filter{TTY: rxnormTTY, SAB: rxnorm}) | |
expandedSABs := toEntries("SNOMEDCT_US", "NCI") | |
conceptsExpanded := []goumls.Concept{} | |
for _, concept := range concepts { | |
related := umlsdb.ConceptsFromCUIS([]string{concept.CUI}, goumls.Filter{SAB: expandedSABs, TTY: expandedTTY}) | |
relatedLabels := []goumls.Label{} | |
for _, relatedConcept := range related { | |
relatedLabels = append(relatedLabels, relatedConcept.Labels...) | |
} | |
concept.Labels = append(concept.Labels, relatedLabels...) | |
conceptsExpanded = append(conceptsExpanded, concept) | |
} | |
log.Println(len(conceptsExpanded)) | |
} | |
func toEntries(list ...string) []goumls.FilterEntry { | |
entries := []goumls.FilterEntry{} | |
for i, _ := range list { | |
entries = append(entries, goumls.FilterEntry{Entry: list[i]}) | |
} | |
return entries | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment