Spaces:
Sleeping
Sleeping
Use replace accordion with tabs for trials
Browse files
app.py
CHANGED
@@ -140,39 +140,36 @@ with st.container():
|
|
140 |
# TODO replace mock data
|
141 |
with open("mock_trial.json") as f:
|
142 |
d = json.load(f)
|
143 |
-
for i in range(0,
|
144 |
trials.append(d)
|
145 |
|
146 |
-
for trial in trials
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
st.table(design_module)
|
177 |
-
|
178 |
-
# TODO more modules?
|
|
|
140 |
# TODO replace mock data
|
141 |
with open("mock_trial.json") as f:
|
142 |
d = json.load(f)
|
143 |
+
for i in range(0, 8):
|
144 |
trials.append(d)
|
145 |
|
146 |
+
tab_titles = [f"{trial['protocolSection']['identificationModule']['nctId']}" for trial in trials]
|
147 |
+
|
148 |
+
def render_tab(trial: dict) -> None:
|
149 |
+
official_title = trial["protocolSection"]["identificationModule"]["officialTitle"]
|
150 |
+
st.write(f"##### {official_title}")
|
151 |
+
|
152 |
+
brief_summary = trial["protocolSection"]["descriptionModule"]["briefSummary"]
|
153 |
+
st.write(brief_summary)
|
154 |
+
|
155 |
+
status_module = {
|
156 |
+
"Status": trial["protocolSection"]["statusModule"]["overallStatus"],
|
157 |
+
"Status Date": trial["protocolSection"]["statusModule"]["statusVerifiedDate"],
|
158 |
+
}
|
159 |
+
st.write("###### Status")
|
160 |
+
st.table(status_module)
|
161 |
+
|
162 |
+
design_module = {
|
163 |
+
"Study Type": trial["protocolSection"]["designModule"]["studyType"],
|
164 |
+
# "Phases": trial["protocolSection"]["designModule"]["phases"], # breaks formatting because it is an array
|
165 |
+
"Allocation": trial["protocolSection"]["designModule"]["designInfo"]["allocation"],
|
166 |
+
"Participants": trial["protocolSection"]["designModule"]["enrollmentInfo"]["count"],
|
167 |
+
}
|
168 |
+
st.write("###### Design")
|
169 |
+
st.table(design_module)
|
170 |
+
|
171 |
+
tabs = st.tabs(tab_titles)
|
172 |
+
|
173 |
+
for i in range(0, len(tabs)):
|
174 |
+
with tabs[i]:
|
175 |
+
render_tab(trials[i])
|
|
|
|
|
|