Rathapoom commited on
Commit
cf4318d
·
verified ·
1 Parent(s): 54d9d0f

Update appbackup.py

Browse files
Files changed (1) hide show
  1. appbackup.py +36 -3
appbackup.py CHANGED
@@ -119,14 +119,47 @@ def main():
119
  format="%.3f"
120
  )
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  # Load constants and medication data
123
  medication_data = load_medication_data()
124
  constants = REGRESSION_CONSTANTS.get(selected_site, {})
125
 
126
- # Generate and display predictions
127
  if st.button("Predict"):
128
- predictions = generate_predictions(medication_data, site, bmd_patient, constants['mu'], constants['sigma'])
129
- display_results(predictions, selected_site)
 
 
 
 
 
130
 
131
  if __name__ == "__main__":
132
  main()
 
119
  format="%.3f"
120
  )
121
 
122
+ # Medication Selection with Checkboxes
123
+ st.subheader("Select Medications to Display")
124
+
125
+ # Add "Show All" Option
126
+ show_all = st.checkbox("Show All Medications")
127
+
128
+ # Define medications by rows
129
+ medication_rows = [
130
+ ["Alendronate", "Risedronate", "Ibandronate oral"],
131
+ ["Zoledronate", "Ibandronate IV (3mg)"],
132
+ ["Denosumab", "Denosumab + Teriparatide"],
133
+ ["Teriparatide", "Teriparatide + Denosumab"],
134
+ ["Romosozumab", "Romosozumab + Denosumab", "Romosozumab + Alendronate"],
135
+ ["Romosozumab + Ibandronate", "Romosozumab + Zoledronate"]
136
+ ]
137
+
138
+ # Create checkboxes for each row
139
+ selected_medications = []
140
+ if not show_all:
141
+ for row in medication_rows:
142
+ cols = st.columns(len(row))
143
+ for col, med in zip(cols, row):
144
+ if col.checkbox(med):
145
+ selected_medications.append(med)
146
+ else:
147
+ # If "Show All" is checked, include all medications
148
+ selected_medications = [med for row in medication_rows for med in row]
149
+
150
  # Load constants and medication data
151
  medication_data = load_medication_data()
152
  constants = REGRESSION_CONSTANTS.get(selected_site, {})
153
 
154
+ # Generate and display predictions for selected medications
155
  if st.button("Predict"):
156
+ all_predictions = generate_predictions(medication_data, site, bmd_patient, constants['mu'], constants['sigma'])
157
+ filtered_predictions = [pred for pred in all_predictions if pred['Drug'] in selected_medications]
158
+
159
+ if not filtered_predictions:
160
+ st.warning("No medications selected. Please select at least one medication or use the 'Show All' option.")
161
+ else:
162
+ display_results(filtered_predictions, selected_site)
163
 
164
  if __name__ == "__main__":
165
  main()