Sentence Entity Resolver for HCPCS Codes

Description

This model maps extracted medical entities to Healthcare Common Procedure Coding System (HCPCS) codes using ‘sbiobert_base_cased_mli’ sentence embeddings.

Predicted Entities

HCPCS Codes

Live Demo 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("sentence_embeddings")

hcpcs_resolver = SentenceEntityResolverModel\
.pretrained("sbiobertresolve_hcpcs", "en", "clinical/models") \
.setInputCols(["ner_chunk", "sentence_embeddings"]) \
.setOutputCol("hcpcs_code")\
.setDistanceFunction("EUCLIDEAN")

hcpcs_pipeline  = Pipeline(
stages = [
documentAssembler,
sbert_embedder,
hcpcs_resolver])

data = spark.createDataFrame([["Breast prosthesis, mastectomy bra, with integrated breast prosthesis form, unilateral, any size, any type"]]).toDF("text")

results = hcpcs_pipeline.fit(data).transform(data)
val documentAssembler = 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")

val hcpcs_resolver = SentenceEntityResolverModel
.pretrained("sbiobertresolve_hcpcs", "en", "clinical/models") 
.setInputCols(Array("ner_chunk", "sentence_embeddings")) 
.setOutputCol("hcpcs_code")
.setDistanceFunction("EUCLIDEAN")

val hcpcs_pipeline = new Pipeline().setStages(Array(documentAssembler, sbert_embedder, hcpcs_resolver))

val data = Seq("Breast prosthesis, mastectomy bra, with integrated breast prosthesis form, unilateral, any size, any type").toDF("text")    

val results = hcpcs_pipeline.fit(data).transform(data)
import nlu
nlu.load("en.resolve.hcpcs").predict("""Breast prosthesis, mastectomy bra, with integrated breast prosthesis form, unilateral, any size, any type""")

Results

+--+---------------------------------------------------------------------------------------------------------+----------+----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|  |ner_chunk                                                                                                |hcpcs_code|all_codes                               |resolutions                                                                                                                                                                                                                                                                                                                                                                                                     |
+--+---------------------------------------------------------------------------------------------------------+----------+----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|0 |Breast prosthesis, mastectomy bra, with integrated breast prosthesis form, unilateral, any size, any type|L8001     |[L8001, L8002, L8000, L8033, L8032, ...]|'Breast prosthesis, mastectomy bra, with integrated breast prosthesis form, unilateral, any size, any type', 'Breast prosthesis, mastectomy bra, with integrated breast prosthesis form, bilateral, any size, any type', 'Breast prosthesis, mastectomy bra, without integrated breast prosthesis form, any size, any type', 'Nipple prosthesis, custom fabricated, reusable, any material, any type, each', ...|
+--+---------------------------------------------------------------------------------------------------------+----------+----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Model Information

Model Name: sbiobertresolve_hcpcs
Compatibility: Healthcare NLP 3.4.0+
License: Licensed
Edition: Official
Input Labels: [sentence_embeddings]
Output Labels: [hcpcs_code]
Language: en
Size: 21.5 MB
Case sensitive: false