Spaces:
Sleeping
Sleeping
Extend trial details
Browse files
app.py
CHANGED
|
@@ -12,7 +12,8 @@ from utils import (
|
|
| 12 |
get_similarities_among_diseases_uris,
|
| 13 |
augment_the_set_of_diseaces,
|
| 14 |
get_clinical_trials_related_to_diseases,
|
| 15 |
-
get_clinical_records_by_ids
|
|
|
|
| 16 |
)
|
| 17 |
from llm_res import get_short_summary_out_of_json_files
|
| 18 |
import json
|
|
@@ -165,31 +166,8 @@ with st.container():
|
|
| 165 |
|
| 166 |
tab_titles = [f"{trial['protocolSection']['identificationModule']['nctId']}" for trial in trials]
|
| 167 |
|
| 168 |
-
def render_tab(trial: dict) -> None:
|
| 169 |
-
official_title = trial["protocolSection"]["identificationModule"]["officialTitle"]
|
| 170 |
-
st.write(f"##### {official_title}")
|
| 171 |
-
|
| 172 |
-
brief_summary = trial["protocolSection"]["descriptionModule"]["briefSummary"]
|
| 173 |
-
st.write(brief_summary)
|
| 174 |
-
|
| 175 |
-
status_module = {
|
| 176 |
-
"Status": trial["protocolSection"]["statusModule"]["overallStatus"],
|
| 177 |
-
"Status Date": trial["protocolSection"]["statusModule"]["statusVerifiedDate"],
|
| 178 |
-
}
|
| 179 |
-
st.write("###### Status")
|
| 180 |
-
st.table(status_module)
|
| 181 |
-
|
| 182 |
-
design_module = {
|
| 183 |
-
"Study Type": trial["protocolSection"]["designModule"]["studyType"],
|
| 184 |
-
# "Phases": trial["protocolSection"]["designModule"]["phases"], # breaks formatting because it is an array
|
| 185 |
-
"Allocation": trial["protocolSection"]["designModule"]["designInfo"]["allocation"],
|
| 186 |
-
"Participants": trial["protocolSection"]["designModule"]["enrollmentInfo"]["count"],
|
| 187 |
-
}
|
| 188 |
-
st.write("###### Design")
|
| 189 |
-
st.table(design_module)
|
| 190 |
-
|
| 191 |
tabs = st.tabs(tab_titles)
|
| 192 |
|
| 193 |
for i in range(0, len(tabs)):
|
| 194 |
with tabs[i]:
|
| 195 |
-
|
|
|
|
| 12 |
get_similarities_among_diseases_uris,
|
| 13 |
augment_the_set_of_diseaces,
|
| 14 |
get_clinical_trials_related_to_diseases,
|
| 15 |
+
get_clinical_records_by_ids,
|
| 16 |
+
render_trial_details
|
| 17 |
)
|
| 18 |
from llm_res import get_short_summary_out_of_json_files
|
| 19 |
import json
|
|
|
|
| 166 |
|
| 167 |
tab_titles = [f"{trial['protocolSection']['identificationModule']['nctId']}" for trial in trials]
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
tabs = st.tabs(tab_titles)
|
| 170 |
|
| 171 |
for i in range(0, len(tabs)):
|
| 172 |
with tabs[i]:
|
| 173 |
+
render_trial_details(trials[i])
|
utils.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
| 4 |
from sqlalchemy import create_engine, text
|
| 5 |
import requests
|
| 6 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 7 |
|
| 8 |
username = "demo"
|
| 9 |
password = "demo"
|
|
@@ -190,6 +191,51 @@ def get_clinical_trials_related_to_diseases(
|
|
| 190 |
|
| 191 |
return [{"nct_id": row[0], "distance": row[1]} for row in data]
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
if __name__ == "__main__":
|
| 195 |
username = "demo"
|
|
|
|
| 4 |
from sqlalchemy import create_engine, text
|
| 5 |
import requests
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
+
import streamlit as st
|
| 8 |
|
| 9 |
username = "demo"
|
| 10 |
password = "demo"
|
|
|
|
| 191 |
|
| 192 |
return [{"nct_id": row[0], "distance": row[1]} for row in data]
|
| 193 |
|
| 194 |
+
def to_capitalized_case(string: str) -> str:
|
| 195 |
+
string = string.replace("_", " ")
|
| 196 |
+
if string.isupper():
|
| 197 |
+
return string[0] + string[1:].lower()
|
| 198 |
+
|
| 199 |
+
def list_to_capitalized_case(strings: List[str]) -> str:
|
| 200 |
+
strings = [to_capitalized_case(s) for s in strings]
|
| 201 |
+
return ", ".join(strings)
|
| 202 |
+
|
| 203 |
+
def render_trial_details(trial: dict) -> None:
|
| 204 |
+
# TODO: handle key errors for all cases (→ do not render)
|
| 205 |
+
|
| 206 |
+
official_title = trial["protocolSection"]["identificationModule"]["officialTitle"]
|
| 207 |
+
st.write(f"##### {official_title}")
|
| 208 |
+
|
| 209 |
+
brief_summary = trial["protocolSection"]["descriptionModule"]["briefSummary"]
|
| 210 |
+
st.write(brief_summary)
|
| 211 |
+
|
| 212 |
+
status_module = {
|
| 213 |
+
"Status": to_capitalized_case(trial["protocolSection"]["statusModule"]["overallStatus"]),
|
| 214 |
+
"Status Date": trial["protocolSection"]["statusModule"]["statusVerifiedDate"],
|
| 215 |
+
"Has Results": trial["hasResults"]
|
| 216 |
+
}
|
| 217 |
+
st.write("###### Status")
|
| 218 |
+
st.table(status_module)
|
| 219 |
+
|
| 220 |
+
design_module = {
|
| 221 |
+
"Study Type": to_capitalized_case(trial["protocolSection"]["designModule"]["studyType"]),
|
| 222 |
+
"Phases": list_to_capitalized_case(trial["protocolSection"]["designModule"]["phases"]),
|
| 223 |
+
"Allocation": to_capitalized_case(trial["protocolSection"]["designModule"]["designInfo"]["allocation"]),
|
| 224 |
+
"Primary Purpose": to_capitalized_case(trial["protocolSection"]["designModule"]["designInfo"]["primaryPurpose"]),
|
| 225 |
+
"Participants": trial["protocolSection"]["designModule"]["enrollmentInfo"]["count"],
|
| 226 |
+
"Masking": to_capitalized_case(trial["protocolSection"]["designModule"]["designInfo"]["maskingInfo"]["masking"]),
|
| 227 |
+
"Who Masked": list_to_capitalized_case(trial["protocolSection"]["designModule"]["designInfo"]["maskingInfo"]["whoMasked"])
|
| 228 |
+
}
|
| 229 |
+
st.write("###### Design")
|
| 230 |
+
st.table(design_module)
|
| 231 |
+
|
| 232 |
+
interventions_module = {}
|
| 233 |
+
for intervention in trial["protocolSection"]["armsInterventionsModule"]["interventions"]:
|
| 234 |
+
name = intervention["name"]
|
| 235 |
+
desc = intervention["description"]
|
| 236 |
+
interventions_module[name] = desc
|
| 237 |
+
st.write("###### Interventions")
|
| 238 |
+
st.table(interventions_module)
|
| 239 |
|
| 240 |
if __name__ == "__main__":
|
| 241 |
username = "demo"
|