Full Trial Retrival
Browse filesAdded feature where full set of trial data is retrieved from Firestore DB
app.py
CHANGED
|
@@ -104,12 +104,20 @@ with tab1:
|
|
| 104 |
nct_id = meta.get("nct_id", f"chunk_{i}") # assigns fallback chuck ID if 'nct_id' is missing
|
| 105 |
chunk_text = meta.get("text", "")[:400] # shows the first 400 characters of the trial chunk
|
| 106 |
with st.expander(f"Trial: {nct_id}"): # create an expandable block for each trial
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
if st.button(f"⭐ Bookmark {nct_id}", key=f"bookmark_{i}"):
|
| 110 |
db.collection("Users").document(USER_ID).collection("Bookmarks").document(nct_id).set({
|
| 111 |
"nct_id": nct_id,
|
| 112 |
-
"text":
|
| 113 |
})
|
| 114 |
st.success(f"Bookmarked {nct_id} to Firestore.")
|
| 115 |
|
|
|
|
| 104 |
nct_id = meta.get("nct_id", f"chunk_{i}") # assigns fallback chuck ID if 'nct_id' is missing
|
| 105 |
chunk_text = meta.get("text", "")[:400] # shows the first 400 characters of the trial chunk
|
| 106 |
with st.expander(f"Trial: {nct_id}"): # create an expandable block for each trial
|
| 107 |
+
# Fetch full trial details from Firestore
|
| 108 |
+
trial_doc = db.collection("ClinicalTrials").document(nct_id).get()
|
| 109 |
+
if trial_doc.exists:
|
| 110 |
+
trial_data = trial_doc.to_dict()
|
| 111 |
+
for k, v in trial_data.items():
|
| 112 |
+
st.markdown(f"**{k.replace('_', ' ').title()}:** {v}")
|
| 113 |
+
else:
|
| 114 |
+
st.warning("⚠️ Full trial details not found in Firestore. Showing partial match.")
|
| 115 |
+
st.write(meta.get("text", "")[:400] + "...")
|
| 116 |
+
# add bookmark button instead each expander. Book marks are saved to /users/demo_user/Bookmarks/{nct_id}
|
| 117 |
if st.button(f"⭐ Bookmark {nct_id}", key=f"bookmark_{i}"):
|
| 118 |
db.collection("Users").document(USER_ID).collection("Bookmarks").document(nct_id).set({
|
| 119 |
"nct_id": nct_id,
|
| 120 |
+
"text": meta.get("text", "")[:400]
|
| 121 |
})
|
| 122 |
st.success(f"Bookmarked {nct_id} to Firestore.")
|
| 123 |
|