Mapping RxNorm Codes with Corresponding Treatments

Description

This pretrained model maps RxNorm and RxNorm Extension codes with their corresponding treatment. Treatment refers to which disease the drug is used to treat.

Predicted Entities

treatment

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_treatment_mapper", "en", "clinical/models")\
      .setInputCols(["resolver2chunk"])\
      .setOutputCol("mappings")\
      .setRels(["treatment"])

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_treatment_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|treatment_mapping_result|relation |
+-------------+-----------+------------------------+---------+
|Eviplera     |217010     |Osteoporosis            |treatment|
|Zonalon 50 mg|103971     |Pain                    |treatment|
|Rompun       |1536491    |Pain                    |treatment|
|Glucovance   |284743     |Diabetes Mellitus       |treatment|
|Abbokinase   |204209     |Angiography             |treatment|
+-------------+-----------+------------------------+---------+

Model Information

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