Categories
Pharmacovigilance toolkit

Get drug class(es) of drug

Enter a drug name (generic or brand name) – returns the medication class or classes.

Categories
Pharmacovigilance toolkit

Drugs in class

Select a drug class to get a list of drugs in that class (with manufacturer).

Categories
Pharmacovigilance toolkit

Label grep

Experimental application to allow quick search across USPI and SmPC for multiple drugs.

Paste a comma-separated list of medications (either generic or brand name can be used).

Press fetch.

Enter a search term.

Simple clinical reasoning using Kanren

Here’s an example of construction of a tiny ontology and use of a particularly robust logic programming system — Dan Friedman and Oleg Kiselyov’s Kanren and a functional language like Scheme:

;; Assert a few simple facts
(define causes
(extend-relation (a1 a2)
(fact () ‘schizophrenia ‘paranoia)
(fact () ‘depression ‘paranoia)
(fact () ‘depression ‘anhedonia)
(fact () ‘depression ‘insomnia)))

;; We can also add facts to our little ontology
(define causes
(extend-relation (a1 a2) causes
(fact () ‘(bipolar disorder) ‘paranoia)))
(define causes
(extend-relation (a1 a2) causes
(fact () ‘(bipolar disorder) ‘mania)))
(define causes
(extend-relation (a1 a2) causes
(fact () ‘(bipolar disorder) ‘insomnia)))

;; Establish relationship of anatomical structures
(define caudal-to
(extend-relation (a1 a2)
(fact () ‘capsule ‘midbrain)
(fact () ‘midbrain ‘pons)
(fact () ‘pons ‘medulla)
(fact () ‘medulla ‘cord)))

(define crosses-at
(extend-relation (a1)
(fact () ‘pons)))

(define caudal-all
(lambda (cephalic caudal)
(any
(adjacent cephalic caudal)
(exists (intermediate)
(all (adjacent cephalic intermediate)
(caudal-all intermediate caudal))))))

(define ipsilateral-symptoms?
(lambda (lesion-at)
(names (solve 5 (x)
(caudal-all lesion-at
(car (names
(solve 5 (s) (crosses-at s))))))))

;; Prettify solutions a bit
(define names
(lambda (ls)
(map car
(map cdr
(map car ls)))))

;; Try a simple relationship query:
;; What symptoms can depression cause?
;; (solve 5 …) means ‘give me at most 5 solutions
;; for the logic variable x that would make
;; (causes ‘depression x) true.
> (names (solve 5 (x) (causes ‘depression x)))
(paranoia anhedonia insomnia)

;; What symptoms can bipolar disorder cause?
> (names (solve 5 (x) (causes ‘(bipolar disorder) x)))
(paranoia mania insomnia)

;; What conditions cause paranoia?
> (names (solve 5 (x) (causes x ‘paranoia)))
(schizophrenia depression (bipolar disorder))

;; What structure is immediately caudal to the midbrain?
> (names (solve 5 (x) (caudal-to ‘midbrain x)))
(pons)

;; What are *all* structures caudal to midbrain?
> (names (solve 5 (x) (caudal-all ‘midbrain x)))
(pons medulla cord)

;; What structure is cephalic to the pons?
;; (Note reordering of terms in the predicate.
;; You can read this logic statement as ‘give me
;; all answers such that x makes predicate caudal-all true’
> (names (solve 5 (x) (caudal-to x ‘pons)))
(midbrain)

;; Give all terms cephalic to pons:
> (names (solve 5 (x) (caudal-all x ‘pons)))
(midbrain capsule)

;; Are symptoms ipsilateral to a given lesion location?
> (ipsilateral-symptoms? ‘cord)
() ;; i.e., false (empty list)

> (ipsilateral-symptoms? ‘medulla)
(_.0) ;; i.e., true for all

These are trivial examples. However, very sophisticated systems can be constructed using logical rather than declarative programming models.

Logic programming has traditionally been done in Prolog. However, systems like the Kanren family (eg, Minikanren) can be embedded in languages like Scheme, Lisp, and Haskell to take advantage of a functional paradigm. Compilation is possible to lower level languages like C for easy porting to various platforms, including ubiquitous portable computers.

For a good introduction to the use of logic programming embedded in a functional language like Scheme, see sections 4.3 – 4.4 of SICP [1].

Much of the current talk around clinical software unfortunately stops at electronic health records (EHR) – the paper chart (with all its limitations) mirrored in various incarnations of ‘the cloud’ (with the additional disadvantage of confidentiality rot). For all the endless effort put into EHR, it was a problem solved long ago with nothing more than punched-card-fed mainframes. All we are seeing now is the iterative pursuit of competing data interchange platforms.

Physicians and researchers need software that advances the goal of making routine things routine beyond just the level of data storage and retrieval…to decision support, data discovery and visualizationunsupervised ontology construction, learning, and scripting of reasoning agents.

Historical attempts at decision support include Mycin for diagnosing infectious blood diseases, which contained assertions and rules in the form if IF-THEN clauses:

IF
the site of the culture is blood, AND the organism gram +, AND
the original infectious site was the GI tract, AND
the abdomen is the locus of infection, OR
the pelvis is the locus of infection
THEN
therapy should cover Enterobacteriaceae

Rules structured in this manner are brittle, and don’t use unification. Such a system, for example, would not robustly provide answers to queries for all flora that would be likely found in a pelvic infection. The narrow domains and lack of some of what we might call “common sense” knowledge can be problematic: H.R. Ekbia [1] humorously notes that querying a medical inference engine for suggestions on what could be causing the reddish-brown spots on the chassis and body of your Jeep, you’d get “measles”. Another medical support program, asked to suggest treatment for bacterial infection in the kidney, suggested boiling the kidney in hot water.

Another decision support system of historical interest was Internist-I – a system with a much broader domain of medical rules and knowledge. Here’s a transcript of a consultation with that system.

References:

[1] Abelson H, Sussman GJ, Sussman J. Structure and Interpretation of Computer Programs, 2nd Edition. 1996, MIT Press, Cambridge MA.
[2] Ekbia, HR. Artificial Dreams – The Quest for Non-Biological Intelligence. 2008, Cambridge University Press, ppg 96-97.

Allen’s temporal calculus

I ported Allen’s temporal calculus to Racket (Scheme) – details here.

Query for medications containing acetaminophen

Hepatotoxicity due to excessive acetaminophen exposure and idiosyncratic drug reactions are now the most common causes of acute liver failure in the United States, surpassing liver failure from viral hepatitis [1-2]. A lack of awareness for how frequently acetaminophen is found in medications may contribute to overexposure.

(Code on Github)

# Use National Library of Medicine’s RXNorm API to
# find medications containing a given ingredient

import requests, json, urllib

def name_resolve_json (name):
# Give a possibly ambiguous name, returns a list of possible matches ranked
# by a likelihood score
s = ‘http://rxnav.nlm.nih.gov/REST/approximateTerm?term=xx&maxEntries=3’.replace(‘xx’, urllib.quote(name))
r = requests.get(s, headers={‘Accept’: ‘application/json’, ‘charset’: ‘UTF-8’})
return r.json()

def first_ranked_cui (approximates):
# Just return the identifier for the best match by score
return extract_from_json(approximates, "candidate", l=[])[0][0][‘rxcui’]

def contains (cui_l):
# Give a list of ingredient identifiers, return drugs which contain
# those ingredients
sl = ‘+’.join(cui_l)
s = ‘http://rxnav.nlm.nih.gov/REST/brands?ingredientids=xx’.replace(‘xx’, sl)
r = requests.get(s, headers={‘Accept’: ‘application/json’, ‘application/json’ ‘charset’: ‘UTF-8’})
return r.json()

def extract_from_json (data, key, l=[]):
# Extract a list of value(s) from a key in
# a (potentially deeply) nested json object
if isinstance(data, list):
for item in data:
extract_from_json(item, key, l)
elif isinstance(data, dict):
for k, v in data.iteritems():
if (k == key):
l.append(v)
extract_from_json(v, key, l)
return l

cv = contains([first_ranked_cui(name_resolve_json(‘acetaminophen’))])
cl = extract_from_json(cv, "name", l=[])
print "{0} medications contain acetaminophen:".format(len(cl))
print "\n".join(cl)
406 medications contain acetaminophen:
 
666 Cold Preparation
Acephen
Acetadrink
Acetadryl
Actamin
Actifed Cold & Sinus
Actifed Plus
Acuflex
Adprin B
Alagesic
Ali Flex
Alka-Seltzer Cold and Sinus
Alka-Seltzer Plus Cold
Alka-Seltzer Plus Cold Liquigel
Alka-Seltzer Plus Cold and Sinus
Alka-Seltzer Plus Cough and Cold Liquigel
Alka-Seltzer Plus Cough and Cold Liquigel Reformulated Aug 2011
Alka-Seltzer Plus Day Severe Cold, Cough And Flu
Alka-Seltzer Plus Flu Liquigels
Alka-Seltzer Plus Flu Reformulated Jan 2011
Alka-Seltzer Plus Night Cold and Flu
Alka-Seltzer Plus Night Severe Cold, Cough and Flu
Alka-Seltzer Plus Night Time Cold Liquigel
Alka-Seltzer Plus Night Time Reformulated Dec 2006
Alka-Seltzer Plus Severe Allergy
Alka-Seltzer Plus Severe Sinus Congestion and Cough
Allerest Headache Strength
Allerest No Drowsiness
Allerest Sinus
Alpain
Anabar
Anacin AF
Anacin Advanced Headache Formula
Anacin PM Aspirin Free
Anexsia
Anolor
Apra
Arthriten Inflammatory Pain
BF-Paradac
BP Poly-650
Backaid
Backaid IPF
Backprin
Bactimicina
Baczol Cold Medicine
Balacet
Bayer Migraine
Bayer Select Decongestant
Benadryl Allergy Cold
Benadryl Allergy Cold Reformulated Jun 2007
Benadryl Severe Allergy Sinus Headache Reformulated Jun 2007
Bromo Seltzer
Bupap
By Ache
Cafgesic
Capacet
Capital and Codeine
Cephadyn
Cetafen
Children’s Mucinex Multi-Symptom Cold and Fever
Childrens Tylenol Cold Plus Cough
Childrens Tylenol Plus Cold & Allergy
Co-Gesic
Cocet
Codrix
Comtrex Allergy Sinus
Comtrex Cold and Cough Nighttime
Comtrex Cold and Cough Non Drowsy
Comtrex Cold and Flu Maximum Strength Liquid
Comtrex Cold and Flu Maximum Strength Reformulated Aug 2006
Comtrex Deep Chest Cold Non Drowsy
Comtrex Nighttime Acute Head Cold
Comtrex Non-Drowsy
Comtrex Sore Throat Relief
Contac Cold and Flu Cooling Night
Contac Cold and Flu Maximum Strength
Contac Cold and Flu Non Drowsy Maximum Strength
Contac Severe Cold and Flu Non Drowsy
Contragesic
Coricidin
Coricidin D Cold
Coricidin HBP Flu Maximum Strength
Coricidin HBP Nighttime Multi-Symptom Cold Reformulated Feb 2013
Coricidin Night Time Cold Relief
Cotabflu
CounterAct Pain
Counteract Day
Counteract Night
Counteract PM
Darvocet
DayQuil Sinex
Dayquil
Dayquil Cold & Flu
Dayquil Liquicaps Reformulated Apr 2009
Dayquil Sinus
Delsym Adult Night Time Multi-Symptom
Delsym Children’s Nighttime Cough and Cold Reformulated Apr 2013
Delsym Cough Plus Cold Daytime
Delsym Cough Plus Cold Night Time
Delsym Night Time Cough and Cold
Diabetic Tussin Night Time Formula
Dilotab
Dimetapp Nighttime Flu
Dimetapp Nighttime Flu Reformulated Sep 2007
Dolacet
Dolgic LQ
Dolgic Plus
Dologen
Dologesic
Dolorex Forte
Dristan Cold
Dristan Cold Multi Symptom
Drixoral Sinus
Durabac
Durabac Forte
Duraflu
Duraxin
EZ III
Ed Flex
Elixsure Fever/Pain
Emagrin Forte
Endocet
Ephed Plus Cold Flu and Sinus
Epidrin
Esgic
Exaprin
Excedrin
Excedrin Aspirin Free
Excedrin Back & Body
Excedrin PM
Excedrin Quick Tab
Excedrin Sinus
Excedrin Sinus Headache
Excedrin Tension Headache
Feverall
Fioricet
Fioricet with Codeine
Flextra
Flextra Plus
Frenadol
Genapap
Geone
Goody’s Body Pain
Goody’s Extra Strength
Goody’s Headache Relief Shot
Goody’s Migraine Relief
Goody’s PM
Histenol
Hy-Phen
Hycet
Infantaire
Kolephrin
Kolephrin DM
Lagesic
Legatrin PM
Levacet
Liquicet
Little Colds
Little Fevers
Lorcet
Lortab
Lusonex Plus
Lynox
Magnacet
Mapap
Mapap Cold Formula
Mapap PM
Mapap Sinus Congestion and Pain
Margesic
Margesic-H
Marten-Tab
Maxidone
Maxiflu CD
Maxiflu DM
Medigesic
Mejoralito
Midol Maximum Strength Menstrual
Midol PM
Midol PM Reformulated Apr 2011
Midol PMS Maximum Strength
Midol Teen
Midrin
Mucinex Children’s Night Time Multi-Symptom Cold
Mucinex Fast-Max Cold and Sinus
Mucinex Fast-Max Cold, Flu and Sore Throat
Mucinex Fast-Max Night Time Cold and Flu
Mucinex Fast-Max Severe Cold
Mucinex Sinus-Max Day
Mucinex Sinus-Max Night
Mygrex
Nature Fusion Cold & Flu
Nonbac
Norco
Norel AD
Norel SR
Nortemp
Novagesic
NyQuil D
NyQuil Sinex
Nyquil Alcohol Free
Nyquil Cold & Flu
Nyquil Multi-Symptom
Ofirmev
Onetab Cold and Flu
Onset Forte
Orbivan
Orbivan CF
Ornex
Painaid
Painaid BRF
Painaid ESF
Pamprin Cramp Formula
Pamprin Max Formula
Pamprin Multi-Symptom
Panadol
Panadol Cold & Flu Non Drowsy
Panadol PM
Pancold S
Panlor DC Reformulated Jan 2008
Panlor SS
PediaCare Children’s Plus Cough and Sore Throat
Pediacare Children’s Fever Reducer Pain Reliever
Pediacare Children’s Plus Cough and Runny Nose
Pediacare Infant Fever Reducer
Percocet
Percogesic Reformulated Jan 2011
Pharbetol
Phenflu CD
Phenflu DM
Phrenilin
Phrenilin with Caffeine and Codeine
Poly-Vent Plus
Premsyn PMS
Primalev
Prodrin
Promacet
Protid
Pyrroxate Cold & Congestion
Redutemp
Relagesic
Repan
Respa C&C
Rhinoflex
Rhinogesic
Rid-A-Pain
Ringl
Robitussin Cold Cough and Flu
Robitussin Honey Flu Nighttime
Robitussin Honey Flu Non-Drowsy
Robitussin Night Cold
Robitussin Night Relief
Robitussin Peak Cold Daytime Cold Plus Flu
Robitussin Peak Cold Nasal
Robitussin Peak Cold Nighttime Cold Plus Flu
Robitussin Peak Cold Nighttime Multi-Symptom Cold
Robitussin Peak Cold Nighttime Nasal Relief
Roxicet
Rx-Act Cold Head Congestion
Rx-Act Flu & Severe Cold & Cough
Rx-Act Flu & Sore Throat
Rx-Act Headache Formula
Rx-Act Nighttime
Rx-Act Pain Relief
Rx-Act Pain Relief PM
Rx-Act Sinus Congestion & Pain
Saleto
SanaTos Night
Sanatos Day
Scot-Tussin Multisymptom Cold and Allergy
Sedalmex
Sedapap
Silapap
Sinarest
Sinarest Sinus
Sine-Off Cold and Cough
Sine-Off Maximum Strength
Sine-Off Maximum Strength Reformulated Sep 2008
Sine-Off Sinus and Cold
Singlet
Sinutab Ex-Strength
Sinutab Sinus
St. Joseph Aspirin-Free
Stagesic
Stona
Sudafed PE Cold & Cough
Sudafed PE Nighttime Cold
Sudafed PE Pressure Plus Pain Plus Cough
Sudafed PE Pressure Plus Pain Plus Mucus
Sudafed PE Severe Cold
Sudafed PE Sinus Headache
Sudafed PE Triple Action
Sudafed Triple Action
Supac
Syncol
T-Painol
T-Painol Extra Strength
Tactinal
Talacen
Tavist Allergy/Sinus/Headache
Tavist Sinus
Tempra
Tempra 2
Tempra Quicklets
Tencon
Theraflu Cold & Sore Throat
Theraflu Cold & Sore Throat Reformulated Sep 2008
Theraflu Daytime Severe Cold
Theraflu Daytime Severe Cold & Cough
Theraflu Flu & Chest Congestion
Theraflu Flu & Sore Throat
Theraflu Flu & Sore Throat Reformulated Sep 2008
Theraflu Flu and Cold Medicine Powder
Theraflu Max-D
Theraflu Nighttime Maximum Strength
Theraflu Nighttime Severe Cold
Theraflu Nighttime Severe Cold & Cough
Theraflu Nighttime Severe Cold Capsule
Theraflu Severe Cold & Congestion Non-Drowsy
Theraflu Severe Cold Nighttime
Theraflu Sore Throat Maximum Strength
Theraflu Warming Cold & Chest Congestion
Theraflu Warming Relief
Theraflu, Flu, Cold, and Cough
Trezix
Trezix Reformulated Oct 2011
Triaminic Cold and Fever
Triaminic Cough & Sore Throat
Triaminic Cough & Sore Throat Reformulated Jul 2007
Triaminic Fever & Pain
Triaminic Infant Drops Reformulated Nov 2010
Triaminic Multi-Symptom Fever
Triaminic Softchews Allergy Sinus
Triaminic Softchews Cough & Sore Throat
Triaminic Softchews Cough & Sore Throat Reformulated Jul 2007
Triaminic Sore Throat Formula
Triaminicin
Tycolene
Tylenol
Tylenol Allergy Multi-Symptom
Tylenol Allergy Multi-Symptom Nighttime
Tylenol Allergy Sinus
Tylenol Chest Congestion
Tylenol Children’s Multi-Symptom Cold Plus
Tylenol Children’s Plus Cold
Tylenol Children’s Plus Cold & Cough
Tylenol Children’s Plus Cold Reformulated Mar 2013
Tylenol Childrens Plus Cough & Runny Nose
Tylenol Childrens Plus Cough & Sore Throat
Tylenol Cold
Tylenol Cold & Flu Severe Day Time
Tylenol Cold Complete Formula
Tylenol Cold Head Congestion Severe
Tylenol Cold Multi-Symptom Daytime
Tylenol Cold Multi-Symptom Nighttime
Tylenol Cold Multi-Symptom Nighttime Liquid
Tylenol Cold Multi-Symptom Severe Daytime
Tylenol Cold Relief Nighttime
Tylenol Cold Severe Congestion Non-Drowsy
Tylenol Cough & Sore Throat Night Time
Tylenol Cough and Sore Throat Daytime
Tylenol Flu Maximum Strength Nighttime
Tylenol PM
Tylenol Severe Allergy
Tylenol Sinus
Tylenol Sinus Congestion and Pain Daytime
Tylenol Sinus Congestion and Pain Severe
Tylenol Sinus NightTime
Tylenol Sinus Severe Congestion
Tylenol with Codeine
Tylox
Ultracet
Un-Aspirin
Uniserts
Unisom with Pain Relief
Valorin Extra
Vanquish
Vicks 44 Cold, Flu and Cough
Vicks Formula 44 Custom Care Cough & Cold PM
Vicks Formula 44M
Vicks Nature Fusion Cold and Flu Night
Vicodin
Vistra
Vitapap
Vopac
Wal-Dryl Severe Allergy & Sinus
Wal-Flu Cold and Sore Throat
Wal-Flu Daytime Severe Cold and Cough
Wal-Flu Flu and Sore Throat
Wal-Flu Severe Cold
Wal-Flu Severe Cold and Cough
Wal-Phed Cold & Cough
Wal-Phed PE Severe Cold
Womens Tylenol Menstrual Relief
XL-DOL
Xodol
Xolox
Yinchiao Fast Relief Flu
Zamicet
Zebutal
Zflex
Zgesic
Zicam Flu Nighttime
Zicam Multi-Symptom Cold and Flu Daytime
Zicam Multi-Symptom Cold and Flu Nighttime
Zolvit
Zydone

[1] Sood GK et al. Acute Liver Failure Medscape eMedicine Reference, August 20, 2012.
[2] George Ostapowicz, Robert J. Fontana, Frank V. Schiødt, Anne Larson, Timothy J. Davern, Steven H.B. Han, Timothy M. McCashland, A. Obaid Shakil, J. Eileen Hay, Linda Hynan, Jeffrey S. Crippin, Andres T. Blei, Grace Samuel, Joan Reisch, William M. Lee, the U.S. Acute Liver Failure Study Group; Results of a Prospective Study of Acute Liver Failure at 17 Tertiary Care Centers in the United States. Annals of Internal Medicine. 2002 Dec;137(12):947-954.

Reactive documents to illustrate basic epidemiology

These are some interactive, reactive documents I wrote to help students understand some basic epidemiological/statistical calculations.

(Source on github)

These documents make use of the excellent tangle and D3libraries.

Smoke Creek

\[ \left\{ \begin{split} & \boldsymbol{\nabla} \cdot \boldsymbol{E} = \frac{\rho}{\varepsilon_0} \\ & \boldsymbol{\nabla} \cdot \boldsymbol{B} = 0 \\ & \boldsymbol{\nabla} \times \boldsymbol{E} = – \frac{\partial \boldsymbol{B}}{\partial t} \\ & \boldsymbol{\nabla} \times \boldsymbol{B} = \mu_0 \boldsymbol{J} + \varepsilon_0 \mu_0 \frac{\partial \boldsymbol{E}}{\partial t} \end{split} \right. \]