Mapping RxNorm Codes with Corresponding Actions and Treatments

Description

This pretrained model maps RxNorm and RxNorm Extension codes with their corresponding action and treatment. Action refers to the function of the drug in various body systems; treatment refers to which disease the drug is used to treat.

Predicted Entities

action, treatment

Open in Colab Copy S3 URI

How to use

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


sbert_embedder = BertSentenceEmbeddings.pretrained('sbiobert_base_cased_mli', 'en','clinical/models')\
.setInputCols(["ner_chunk"])\
.setOutputCol("sentence_embeddings")\
.setCaseSensitive(False)

rxnorm_resolver = SentenceEntityResolverModel.pretrained("sbiobertresolve_rxnorm_augmented","en", "clinical/models") \
.setInputCols(["sentence_embeddings"]) \
.setOutputCol("rxnorm_code")\
.setDistanceFunction("EUCLIDEAN")


chunkerMapper_action = ChunkMapperModel.pretrained("rxnorm_action_treatment_mapper", "en", "clinical/models")\
.setInputCols(["rxnorm_code"])\
.setOutputCol("Action")\
.setRel("Action") 


chunkerMapper_treatment = ChunkMapperModel.pretrained("rxnorm_action_treatment_mapper", "en", "clinical/models")\
.setInputCols(["rxnorm_code"])\
.setOutputCol("Treatment")\
.setRel("Treatment") 


pipeline = Pipeline().setStages([document_assembler,
sbert_embedder,
rxnorm_resolver,
chunkerMapper_action,
chunkerMapper_treatment
])


model = pipeline.fit(spark.createDataFrame([['']]).toDF('text')) 

light_pipeline = LightPipeline(model)

result = light_pipeline.annotate(['Sinequan 150 MG', 'Zonalon 50 mg'])
val document_assembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("ner_chunk")


val sbert_embedder = BertSentenceEmbeddings.pretrained("sbiobert_base_cased_mli", "en","clinical/models")
.setInputCols(Array("ner_chunk"))
.setOutputCol("sentence_embeddings")
.setCaseSensitive(False)

val rxnorm_resolver = SentenceEntityResolverModel.pretrained("sbiobertresolve_rxnorm_augmented","en", "clinical/models")
.setInputCols(Array("sentence_embeddings"))
.setOutputCol("rxnorm_code")
.setDistanceFunction("EUCLIDEAN")


val chunkerMapper_action = ChunkMapperModel.pretrained("rxnorm_action_treatment_mapper", "en", "clinical/models"))
.setInputCols("rxnorm_code")
.setOutputCol("Action")
.setRel("Action") 


val chunkerMapper_treatment = ChunkMapperModel.pretrained("rxnorm_action_treatment_mapper", "en", "clinical/models"))
.setInputCols("rxnorm_code")
.setOutputCol("Treatment")
.setRel("Treatment") 


val pipeline = new Pipeline().setStages(Array(document_assembler,
sbert_embedder,
rxnorm_resolver,
chunkerMapper_action,
chunkerMapper_treatment
))


val text_data = Seq("Sinequan 150 MG", "Zonalon 50 mg").toDS.toDF("text")
val res = pipeline.fit(text_data).transform(text_data)
import nlu
nlu.load("en.map_entity.rxnorm_to_action_treatment").predict("""Sinequan 150 MG""")

Results

|    | ner_chunk           | rxnorm_code   | Treatment                                                                      | Action                                                                 |
|---:|:--------------------|:--------------|:-------------------------------------------------------------------------------|:-----------------------------------------------------------------------|
|  0 | ['Sinequan 150 MG'] | ['1000067']   | ['Alcoholism', 'Depression', 'Neurosis', 'Anxiety&Panic Attacks', 'Psychosis'] | ['Antidepressant', 'Anxiolytic', 'Psychoanaleptics', 'Sedative']       |
|  1 | ['Zonalon 50 mg']   | ['103971']    | ['Pain']                                                                       | ['Analgesic', 'Analgesic (Opioid)', 'Analgetic', 'Opioid', 'Vitamins'] |


Model Information

|—|—| |Model Name:|rxnorm_action_treatment_mapper| |Compatibility:|Healthcare NLP 3.5.1+| |License:|Licensed| |Edition:|Official| |Input Labels:|[chunk]| |Output Labels:|[mappings]| |Language:|en| |Size:|19.3 MB|