| Literature DB >> 34889749 |
Youcheng Pan1, Chenghao Wang1, Baotian Hu1, Yang Xiang2, Xiaolong Wang1, Qingcai Chen1,2, Junjie Chen1, Jingcheng Du3.
Abstract
BACKGROUND: Electronic medical records (EMRs) are usually stored in relational databases that require SQL queries to retrieve information of interest. Effectively completing such queries can be a challenging task for medical experts due to the barriers in expertise. Existing text-to-SQL generation studies have not been fully embraced in the medical domain.Entities:
Keywords: BERT; electronic medical record; grammar-based decoding; text-to-SQL generation; tree-structured intermediate representation
Year: 2021 PMID: 34889749 PMCID: PMC8701710 DOI: 10.2196/32698
Source DB: PubMed Journal: JMIR Med Inform
Figure 1Application scenario of medical text–to-SQL generation.
The summary of the MIMICSQL dataset.
| Type | Count |
| Patients, n | 46,520 |
| Tables, n | 5 |
| Columns in tablesa, n | 23/5/5/7/9 |
| Question-SQL pairs, n | 10,000 |
| Template question length (in words), mean | 18.39 |
| Rephrased question length (in words), mean | 16.45 |
| SQL query length, mean | 21.14 |
| Aggregation columns, mean | 1.1 |
| Conditions, mean | 1.76 |
aThe 23/5/5/7/9 correspond to the numbers of columns in the Demographics/Diagnosis/Procedure/Prescriptions/Laboratory tests tables.
Figure 2Overview of our proposed method of medical text–to-SQL task. LSTM: long short-term memory.
Figure 3Example of tree-structured intermediate representation: (a) grammar rules that transform the SQL query into an abstract syntax tree, (b) example of the action sequence generated by the grammar-based decoder with 4 types of actions, and (c) intermediate tree constructed from the action sequence in b following the grammar rules in a.
The logic form accuracy (Acc) and execution accuracy (Acc) of SQL query generated by various methods.
| Methods | Validation | Test | ||
|
|
|
|
|
|
| Seq2Seq | 0.092 | 0.195 | 0.103 | 0.173 |
| SQLNet | 0.086 | 0.225 | 0.142 | 0.260 |
| PtrGen | 0.181 | 0.325 | 0.180 | 0.292 |
| Coarse2Fine | 0.217 | 0.309 | 0.378 | 0.496 |
| TREQS | 0.562 | 0.675 | 0.556 | 0.654 |
| MedTS | 0.681 | 0.880 | 0.784 | 0.899 |
aAcc: logic form accuracy.
bAcc: execution accuracy.
Accuracy of each component of SQL query.
| Methods | Validation | Test | |||||||||
|
|
|
|
|
|
|
|
|
|
|
| |
| Coarse2Fine | 0.321 | 0.313 | 0.321 | 0.260 | 0.214 | 0.524 | 0.490 | 0.528 | 0.448 | 0.413 | |
| Seq2Seq | 0.978 | 0.872 | 0.926 | 0.471 | 0.174 | 0.970 | 0.696 | 0.892 | 0.565 | 0.296 | |
| SQLNet | 0.994 | 0.939 | 0.933 | 0.722 | 0.080 | 0.989 | 0.873 | 0.941 | 0.749 | 0.140 | |
| PtrGen | 0.987 | 0.917 | 0.944 | 0.795 | 0.236 | 0.987 | 0.830 | 0.926 | 0.824 | 0.235 | |
| TREQS | 0.990 | 0.912 | 0.942 | 0.834 | 0.694 | 0.993 | 0.827 | 0.941 | 0.844 | 0.763 | |
| MedTS | 0.994 | 0.988 | 0.971 | 0.893 | 0.785 | 0.991 | 0.985 | 0.951 | 0.919 | 0.851 | |
aAgg: aggregation.
bOp: operation.
cCol: column.
dCon: condition.
ec+o: column and operation.
fVal: value.
The experimental results of the ablation study.
| Methods | Validation | Test | |||||||
|
|
|
|
|
| |||||
|
| 0.681 | 0.880 | 0.784 | 0.899 | |||||
|
| w/o SL | 0.669 | 0.870 | 0.773 | 0.887 | ||||
|
| w/ BioWord2Vec | 0.472 | 0.690 | 0.501 | 0.644 | ||||
|
| w/ ClinicalBERT | 0.556 | 0.771 | 0.634 | 0.784 | ||||
|
| w/ BioBERT | 0.684 | 0.882 | 0.790 | 0.904 | ||||
aAcc: logic form accuracy.
bAcc: execution accuracy.
Five representative examples of qualitative case study.
| Examples | |
|
| |
|
| Qa: Let me know the short title and ICD-9b codes of diagnoses for patient John Gartman. |
|
| Gc: Select diagnoses.“icd9_code,” diagnoses.“short_title” from demographic inner join diagnoses on demographic.hadm_id = diagnoses.hadm_id where demographic.“name” = “john gartman” |
|
| Pd: Select diagnoses.“icd9_code,” diagnoses.“short_title” from diagnoses inner join demographic on diagnoses.hadm_id = demographic.hadm_id where demographic.“name” = “john gartman” |
|
| |
|
| Q: Tell me which primary disease the patient Walter Locher is suffering from and whether he is still alive or not. |
|
| G: Select demographic.“expire_flag,” demographic.“diagnosis” from demographic where demographic.“name” = “walter locher” |
|
| P: Select demographic.“diagnosis,” demographic.“expire_flag” from demographic where demographic.“name” = “walter locher” |
|
| |
|
| Q: Calculate the number of dead patients who were admitted to hospital before 2123. |
|
| G: Select count (distinct demographic.“subject_id”) from demographic where demographic.“expire_flag” = “1” and demographic.“admityear” < “2123” |
|
| P: Select count (distinct demographic.“subject_id”) from demographic where demographic.“expire_flag” = “0” and demographic.“admityear” < “2123” |
|
| |
|
| Q: How many American Indian/Alaska Native ethnic background patients were born before 2148? |
|
| G: Select count (distinct demographic.“subject_id”) from demographic where demographic.“ethnicity” = “american indian/alaska native” and demographic.“admityear” < “2148” |
|
| P: Select count (distinct demographic.“subject_id”) from demographic where demographic.“ethnicity” = “american indian/alaska native” and demographic.“dob_year” < “2184” |
|
| |
|
| Q: Find the minimum number of days of hospital stay for patients born before the year 2200. |
|
| G: Select min (demographic.“days_stay”) from demographic where demographic.“dob_year” > “2200” |
|
| P: Select min (demographic.“days_stay”) from demographic where demographic.“dob_year” < “2200” |
aQ: textual question.
bICD-9: International Classification of Diseases Clinical Modification, 9th Revision.
cG: golden truth.
dP: predicted result.
Statistical analysis of error categories.
|
| Select | Join | Where | #Element Error (%) |
| Operator, n | 9 | —a | 3 | 12 (10.6) |
| Table, n | 8 | 6 | — | 14 (12.4) |
| Column, n | 17 | — | 10 | 27 (23.9) |
| Value, n | — | — | 44 | 44 (38.9) |
| Other, n | 4 | 9 | 3 | 16 (14.2) |
| #Clause Error (%) | 38 (33.6) | 15 (13.3) | 60 (53.1) | 113 (100) |
aNot applicable.