Mapping RxNorm Codes with Corresponding Actions

Description

This pretrained model maps RxNorm and RxNorm Extension codes with their corresponding actions. Action refers to the function of the drug in various body systems.

Predicted Entities

action

Open in Colab Copy S3 URI

How to use

documentAssembler = DocumentAssembler()\
      .setInputCol("text")\
      .setOutputCol("ner_chunk")

sbert_embedder = BertSentenceEmbeddings\
      .pretrained("sbiobert_base_cased_mli", "en","clinical/models")\
      .setInputCols(["ner_chunk"])\
      .setOutputCol("sbert_embeddings")\
      .setCaseSensitive(False)
    
rxnorm_resolver = SentenceEntityResolverModel\
      .pretrained("sbiobertresolve_rxnorm_augmented", "en", "clinical/models")\
      .setInputCols(["sbert_embeddings"])\
      .setOutputCol("rxnorm_code")\
      .setDistanceFunction("EUCLIDEAN")

resolver2chunk = Resolution2Chunk()\
    .setInputCols(["rxnorm_code"]) \
    .setOutputCol("resolver2chunk")

chunkMapper = ChunkMapperModel.pretrained("rxnorm_action_mapper", "en", "clinical/models")\
      .setInputCols(["resolver2chunk"])\
      .setOutputCol("mappings")\
      .setRels(["action"])

pipeline = Pipeline(
    stages = [
        documentAssembler,
        sbert_embedder,
        rxnorm_resolver,
        resolver2chunk,
        chunkMapper
        ])

test_data = spark.createDataFrame([["Eviplera"], ["Zonalon 50 mg"], ["Rompun"], ["Glucovance"], ["Abbokinase"]]).toDF("text")

res= model.fit(test_data).transform(test_data)
val documentAssembler = new DocumentAssembler()
    .setInputCol("text")
    .setOutputCol("ner_chunk")

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

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

val resolver2chunk = new Resolution2Chunk()\
    .setInputCols(["rxnorm_code"]) \
    .setOutputCol("resolver2chunk")

val chunkMapper = ChunkMapperModel.pretrained("rxnorm_action_mapper", "en", "clinical/models")
    .setInputCols("resolver2chunk")
    .setOutputCol("mappings")
    .setRels("action")

val pipeline = new Pipeline(stages = Array(
    documentAssembler,
    sbert_embedder,
    rxnorm_resolver,
    resolver2chunk,
    chunkMapper
    ))

val data = Seq(Array("Eviplera", "Zonalon 50 mg", "Rompun", "Glucovance", "Abbokinase")).toDS.toDF("text")

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

Results

+-------------+-----------+--------------------------+--------+
|ner_chunk    |rxnorm_code|action_mapping_result     |relation|
+-------------+-----------+--------------------------+--------+
|Eviplera     |217010     |Inhibitory Bone Resorption|action  |
|Zonalon 50 mg|103971     |Analgesic                 |action  |
|Rompun       |1536491    |Venotonic                 |action  |
|Glucovance   |284743     |Drugs Used In Diabets     |action  |
|Abbokinase   |204209     |Fibrinolytic              |action  |
+-------------+-----------+--------------------------+--------+

Model Information

Model Name: rxnorm_action_mapper
Compatibility: Healthcare NLP 5.2.2+
License: Licensed
Edition: Official
Input Labels: [ner_chunk]
Output Labels: [mappings]
Language: en
Size: 5.7 MB