Mapping Drugs With Their Corresponding Adverse Drug Events (ADE)

Description

This pretrained model maps drugs with their corresponding Adverse Drug Events.

Predicted Entities

ADE

Live Demo Open in Colab Copy S3 URI

How to use

document_assembler = DocumentAssembler()\
      .setInputCol('text')\
      .setOutputCol('document')

sentence_detector = SentenceDetector()\
      .setInputCols(["document"])\
      .setOutputCol("sentence")

tokenizer = Tokenizer()\
      .setInputCols("sentence")\
      .setOutputCol("token")

word_embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")\
      .setInputCols(["sentence", "token"])\
      .setOutputCol("embeddings")

#NER model to detect drug in the text
ner = MedicalNerModel.pretrained('ner_posology_greedy', 'en', 'clinical/models') \
      .setInputCols(["sentence", "token", "embeddings"]) \
      .setOutputCol("ner")

ner_chunk = NerConverter() \
      .setInputCols(["sentence", "token", "ner"]) \
      .setOutputCol("ner_chunk")\

chunkMapper = ChunkMapperModel.pretrained("drug_ade_mapper", "en", "clinical/models")\
      .setInputCols(["ner_chunk"])\
      .setOutputCol("mappings")\
      .setRels(["ADE"])

pipeline = Pipeline().setStages([document_assembler,
                                 sentence_detector,
                                 tokenizer, 
                                 word_embeddings,
                                 ner, 
                                 ner_chunk, 
                                 chunkMapper])

text = ["""The patient was prescribed 1000 mg fish oil and multivitamins. 
            She was discharged on zopiclone and ambrisentan"""]

data = spark.createDataFrame([text]).toDF("text")

result= pipeline.fit(data).transform(data)

val document_assembler = new DocumentAssembler()
      .setInputCol("text")
      .setOutputCol("document")

val sentence_detector = new SentenceDetector()
      .setInputCols(Array("document"))
      .setOutputCol("sentence")

val tokenizer = new Tokenizer()
      .setInputCols("sentence")
      .setOutputCol("token")

val word_embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")
      .setInputCols(Array("sentence", "token"))
      .setOutputCol("embeddings")

#NER model to detect drug in the text
val ner = MedicalNerModel.pretrained("ner_posology_greedy", "en", "clinical/models") 
      .setInputCols(Array("sentence", "token", "embeddings"))
      .setOutputCol("ner")

val ner_chunk = new NerConverter() 
      .setInputCols(Array("sentence", "token", "ner")) 
      .setOutputCol("ner_chunk")

val chunkMapper = ChunkMapperModel.pretrained("drug_ade_mapper", "en", "clinical/models")
      .setInputCols(Array("ner_chunk"))
      .setOutputCol("mappings")
      .setRels(Array("ADE"))

val pipeline = new Pipeline(stages = Array(
                                 document_assembler,
                                 sentence_detector,
                                 tokenizer, 
                                 word_embeddings,
                                 ner, 
                                 ner_chunk, 
                                 chunkMapper))

val data = Seq("The patient was prescribed 1000 mg fish oil and multivitamins. She was discharged on zopiclone and ambrisentan").toDS.toDF("text")

val result= pipeline.fit(data).transform(data)
import nlu
nlu.load("en.map_entity.drug_ade").predict("""The patient was prescribed 1000 mg fish oil and multivitamins. 
            She was discharged on zopiclone and ambrisentan""")

Results

+----------------+------------+-------------------------------------------------------------------------------------------+
|ner_chunk       |ade_mappings|all_relations                                                                              |
+----------------+------------+-------------------------------------------------------------------------------------------+
|1000 mg fish oil|Dizziness   |Myocardial infarction:::Nausea                                                             |
|multivitamins   |Erythema    |Acne:::Dry skin:::Skin burning sensation:::Inappropriate schedule of product administration|
|zopiclone       |Vomiting    |Malaise:::Drug interaction:::Asthenia:::Hyponatraemia                                      |
|ambrisentan     |Dyspnoea    |Therapy interrupted:::Death:::Dizziness:::Drug ineffective                                 |
+----------------+------------+-------------------------------------------------------------------------------------------+

Model Information

Model Name: drug_ade_mapper
Compatibility: Healthcare NLP 4.0.2+
License: Licensed
Edition: Official
Input Labels: [ner_pos_chunk]
Output Labels: [mappings]
Language: en
Size: 7.9 MB

References

Data from the FDA Adverse Event Reporting System (FAERS) for the years 2020, 2021 and 2022 were used as the source for this mapper model.

https://fis.fda.gov/extensions/FPD-QDE-FAERS/FPD-QDE-FAERS.html