Mapping Entities with Corresponding ICD-10-CM Codes

Description

This pretrained model maps entities with their corresponding ICD-10-CM codes.

Important Note: Mappers extract additional information such as extended descriptions and categories related to Concept codes (such as RxNorm, ICD10, CPT, MESH, NDC, UMLS, etc.). They generally take Concept Codes, which are the outputs of EntityResolvers, as input. When creating a pipeline that contains ‘Mapper’, it is necessary to use the ChunkMapperModel after an EntityResolverModel.

Predicted Entities

icd10cm_code

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 = MedicalNerModel\
    .pretrained("ner_clinical", "en", "clinical/models")\
    .setInputCols(["sentence", "token", "embeddings"])\
    .setOutputCol("ner")

ner_converter = NerConverterInternal()\
    .setInputCols("sentence", "token", "ner")\
    .setOutputCol("ner_chunk")\
    .setWhiteList(["PROBLEM"])

chunkerMapper = ChunkMapperModel\
    .pretrained("icd10cm_mapper", "en", "clinical/models")\
    .setInputCols(["ner_chunk"])\
    .setOutputCol("mappings")\
    .setRels(["icd10cm_code"])

mapper_pipeline = Pipeline().setStages([
    document_assembler,
    sentence_detector,
    tokenizer, 
    word_embeddings,
    ner_model, 
    ner_converter, 
    chunkerMapper])


test_data = spark.createDataFrame([["A 35-year-old male with a history of chronic renal insufficiency, type 2 diabetes mellitus diagnosed eight years prior, hypertension, and hyperlipidemia, presented with a two-week history of polydipsia, poor appetite, and vomiting."]]).toDF("text")

mapper_model = mapper_pipeline.fit(test_data)

result= mapper_model.transform(test_data)
val document_assembler = new DocumentAssembler()
    .setInputCol("text")
    .setOutputCol("document")

val sentence_detector = new SentenceDetector()
    .setInputCols("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")

val ner_model = MedicalNerModel
    .pretrained("ner_clinical", "en", "clinical/models")
    .setInputCols(Array("sentence", "token", "embeddings"))
    .setOutputCol("ner")

val ner_converter = new NerConverterInternal()
    .setInputCols(Array("sentence", "token", "ner"))
    .setOutputCol("ner_chunk")\
    .setWhiteList(["PROBLEM"])

val chunkerMapper = ChunkMapperModel
    .pretrained("icd10cm_mapper", "en", "clinical/models")
    .setInputCols("ner_chunk")
    .setOutputCol("mappings")
    .setRels("icd10cm_code")

val mapper_pipeline = new Pipeline().setStages(Array(
    document_assembler,
    sentence_detector,
    tokenizer, 
    word_embeddings,
    ner_model, 
    ner_converter, 
    chunkerMapper))


val data = Seq("A 35-year-old male with a history of chronic renal insufficiency, type 2 diabetes mellitus diagnosed eight years prior, hypertension, and hyperlipidemia, presented with a two-week history of polydipsia, poor appetite, and vomiting.").toDS.toDF("text")

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

Results

+---------------------------+-------+------------+
|ner_chunk                  |entity |icd10cm_code|
+---------------------------+-------+------------+
|chronic renal insufficiency|PROBLEM|N18.9       |
|type 2 diabetes mellitus   |PROBLEM|E11         |
|hypertension               |PROBLEM|I10         |
|hyperlipidemia             |PROBLEM|E78.5       |
|polydipsia                 |PROBLEM|R63.1       |
|poor appetite              |PROBLEM|R63.0       |
|vomiting                   |PROBLEM|R11.1       |
+---------------------------+-------+------------+

Model Information

Model Name: icd10cm_mapper
Compatibility: Healthcare NLP 4.4.2+
License: Licensed
Edition: Official
Input Labels: [ner_chunk]
Output Labels: [mappings]
Language: en
Size: 14.1 MB