Skip to content

Instantly share code, notes, and snippets.

@palexander
Created September 18, 2014 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palexander/68f4cecf433890c439b6 to your computer and use it in GitHub Desktop.
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
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