Detect clinical entities (ner_jsl_biobert)

Description

Detect symptoms, modifiers, age, drugs, treatments, tests and a lot more using a single pretrained NER model.

Definitions of Predicted Entities:

  • Symptom: All the symptoms mentioned in the document, of a patient or someone else.
  • Pulse: Peripheral heart rate, without advanced information like measurement location.
  • Death_Entity: Mentions that indicate the death of a patient.
  • Age: All mention of ages, past or present, related to the patient or with anybody else.
  • Modifier: Terms that modify the symptoms, diseases or risk factors. If a modifier is included in ICD-10 name of a specific disease, the respective modifier is not extracted separately.
  • Substance: All mentions of substance use related to the patient or someone else (recreational drugs, illicit drugs).
  • Drug_Ingredient: Active ingredient/s found in drug products.
  • Weight: All mentions related to a patients weight.
  • Drug_BrandName: Commercial labeling name chosen by the labeler or the drug manufacturer for a drug containing a single or multiple drug active ingredients.
  • Procedure: All mentions of invasive medical or surgical procedures or treatments.
  • Blood_Pressure: Systemic blood pressure, mean arterial pressure, systolic and/or diastolic are extracted.
  • Gender: Gender-specific nouns and pronouns.
  • Temperature: All mentions that refer to body temperature.
  • Section_Header: All the section headers present in the text (Medical History, Family History, Social History, Physical Examination and Vital signs Headers are extracted separately with their specific labels).
  • Route: Drug and medication administration routes available described by FDA.
  • O2_Saturation: Systemic arterial, venous or peripheral oxygen saturation measurements.
  • Respiration: Number of breaths per minute.
  • Procedure: All mentions of invasive medical or surgical procedures or treatments.
  • Frequency: Frequency of administration for a dose prescribed.
  • Dosage: Quantity prescribed by the physician for an active ingredient; measurement units are available described by FDA.
  • Allergen: Allergen related extractions mentioned in the document.

Predicted Entities

Symptom_Name, Negated, Pulse_Rate, Negation, Date_of_death, Age, Modifier, Substance_Name, Causative_Agents_(Virus_and_Bacteria), Drug_incident_description, Diagnosis, Weight, Drug_Name, Procedure_Name, Lab_Name, Blood_Pressure, Cause_of_death, Lab_Result, Gender, Name, Temperature, Procedure_Findings, Section_Name, Route, Maybe, O2_Saturation, Respiratory_Rate, Procedure, Procedure_incident_description, Frequency, Dosage, Allergenic_substance

Live Demo Open in Colab Copy S3 URI

How to use

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

sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare","en","clinical/models") \
		.setInputCols(["document"]) \
		.setOutputCol("sentence")

tokenizer = Tokenizer()\
		.setInputCols(["sentence"])\
		.setOutputCol("token")
	
embeddings = BertEmbeddings.pretrained("biobert_pubmed_base_cased")\
		.setInputCols(["sentence",  "token"]) \
		.setOutputCol("embeddings")
		
jsl_ner = MedicalNerModel.pretrained("ner_jsl_biobert", "en", "clinical/models") \
		.setInputCols(["sentence", "token", "embeddings"]) \
		.setOutputCol("jsl_ner")

jsl_ner_converter = NerConverter() \
		.setInputCols(["sentence", "token", "jsl_ner"]) \
		.setOutputCol("ner_chunk")

jsl_ner_pipeline = Pipeline().setStages([
				documentAssembler,
				sentenceDetector,
				tokenizer,
				embeddings,
				jsl_ner,
				jsl_ner_converter])


jsl_ner_model = jsl_ner_pipeline.fit(spark.createDataFrame([['']]).toDF("text"))

data = spark.createDataFrame([["""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature."""]]).toDF("text")

result = jsl_ner_model.transform(data)
val documentAssembler = new DocumentAssembler()
		.setInputCol("text")
		.setOutputCol("document")

val sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare", "en", "clinical/models")
		.setInputCols("document") 
		.setOutputCol("sentence")

val tokenizer = new Tokenizer()
		.setInputCols("sentence")
		.setOutputCol("token")
	
val embeddings = BertEmbeddings.pretrained("biobert_pubmed_base_cased")
		.setInputCols(Array("sentence",  "token")) 
		.setOutputCol("embeddings")

val jsl_ner = MedicalNerModel.pretrained("ner_jsl_biobert", "en", "clinical/models")
		.setInputCols(Array("sentence", "token", "embeddings"))
		.setOutputCol("jsl_ner")

val jsl_ner_converter = new NerConverter()
		.setInputCols(Array("sentence", "token", "jsl_ner"))
		.setOutputCol("ner_chunk")

val jsl_ner_pipeline = new Pipeline().setStages(Array(
					documentAssembler, 
					sentenceDetector, 
					tokenizer, 
					embeddings, 
					jsl_ner, 
					jsl_ner_converter))


val data = Seq("""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature.""").toDS.toDF("text")

val result = jsl_ner_pipeline.fit(data).transform(data)
import nlu
nlu.load("en.med_ner.jsl.biobert").predict("""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature.""")

Results

+-------------------------------+------------+
|chunk                          |ner_label   |
+-------------------------------+------------+
|21-day-old                     |Age         |
|male                           |Gender      |
|mom                            |Gender      |
|she                            |Gender      |
|mild                           |Modifier    |
|problems with his breathing    |Symptom_Name|
|negative                       |Negated     |
|perioral cyanosis              |Symptom_Name|
|retractions                    |Symptom_Name|
|mom                            |Gender      |
|Tylenol                        |Drug_Name   |
|His                            |Gender      |
|his                            |Gender      |
|respiratory congestion         |Symptom_Name|
|He                             |Gender      |
|more                           |Modifier    |
|tired                          |Symptom_Name|
|fussy                          |Symptom_Name|
|albuterol                      |Drug_Name   |
|His                            |Gender      |
|urine output has also decreased|Symptom_Name|
|he                             |Gender      |
|he                             |Gender      |
|Mom                            |Gender      |
|denies                         |Negated     |
|diarrhea                       |Symptom_Name|
|His                            |Gender      |
+-------------------------------+------------+

Model Information

|—|—| |Model Name:|ner_jsl_biobert| |Compatibility:|Healthcare NLP 3.0.0+| |License:|Licensed| |Edition:|Official| |Input Labels:|[sentence, token, embeddings]| |Output Labels:|[ner]| |Language:|en|