maseiler commited on
Commit
796a53b
1 Parent(s): 9b5c4aa

Use replace accordion with tabs for trials

Browse files
Files changed (1) hide show
  1. app.py +31 -34
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, 5):
144
  trials.append(d)
145
 
146
- for trial in trials:
147
- with st.expander(f"{trial['protocolSection']['identificationModule']['nctId']}"):
148
- official_title = trial["protocolSection"]["identificationModule"][
149
- "officialTitle"
150
- ]
151
- st.write(f"##### {official_title}")
152
-
153
- brief_summary = trial["protocolSection"]["descriptionModule"]["briefSummary"]
154
- st.write(brief_summary)
155
-
156
- status_module = {
157
- "Status": trial["protocolSection"]["statusModule"]["overallStatus"],
158
- "Status Date": trial["protocolSection"]["statusModule"][
159
- "statusVerifiedDate"
160
- ],
161
- }
162
- st.write("###### Status")
163
- st.table(status_module)
164
-
165
- design_module = {
166
- "Study Type": trial["protocolSection"]["designModule"]["studyType"],
167
- # "Phases": trial["protocolSection"]["designModule"]["phases"], # breaks formatting because it is an array
168
- "Allocation": trial["protocolSection"]["designModule"]["designInfo"][
169
- "allocation"
170
- ],
171
- "Participants": trial["protocolSection"]["designModule"]["enrollmentInfo"][
172
- "count"
173
- ],
174
- }
175
- st.write("###### Design")
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])