Update app.py
Browse files
app.py
CHANGED
|
@@ -145,6 +145,7 @@ def update_cow():
|
|
| 145 |
st.write(f"**Health History**: {cow_info[4]}")
|
| 146 |
st.write(f"**Health Score**: {cow_info[5]}")
|
| 147 |
|
|
|
|
| 148 |
new_breed = st.selectbox("Select New Breed", ['Girolando', 'Jersey', 'Holstein Friesian (HF)', 'Sahiwal', 'Kankrej', 'Gir / Gyr', 'Red Sindhi'], index=['Girolando', 'Jersey', 'Holstein Friesian (HF)', 'Sahiwal', 'Kankrej', 'Gir / Gyr', 'Red Sindhi'].index(cow_info[1]))
|
| 149 |
new_age = st.number_input("Enter New Age (in years)", min_value=0, value=cow_info[2])
|
| 150 |
new_tag_id = st.text_input("Enter New Tag ID", value=cow_info[3])
|
|
@@ -163,10 +164,14 @@ def update_cow():
|
|
| 163 |
|
| 164 |
new_previous_illness = st.selectbox("Previous Illness", ['No', 'Yes'], index=['No', 'Yes'].index(cow_info[4].split('\n')[2].split(": ")[1]))
|
| 165 |
new_previous_diseases = []
|
|
|
|
|
|
|
| 166 |
if new_previous_illness == 'Yes':
|
| 167 |
existing_previous_diseases = cow_info[4].split('\n')[2].split(": ")[1]
|
|
|
|
| 168 |
existing_previous_diseases = existing_previous_diseases.split(", ") if existing_previous_diseases != 'None' else []
|
| 169 |
-
|
|
|
|
| 170 |
|
| 171 |
# Reproductive Status handling (as string)
|
| 172 |
reproductive_status_list = ['Not Applicable', 'Estrus Period', 'Gestation Period', 'Adult/Milking Stage', 'Pregnant/Calving Stage']
|
|
|
|
| 145 |
st.write(f"**Health History**: {cow_info[4]}")
|
| 146 |
st.write(f"**Health Score**: {cow_info[5]}")
|
| 147 |
|
| 148 |
+
# Pre-fill the form with the existing data
|
| 149 |
new_breed = st.selectbox("Select New Breed", ['Girolando', 'Jersey', 'Holstein Friesian (HF)', 'Sahiwal', 'Kankrej', 'Gir / Gyr', 'Red Sindhi'], index=['Girolando', 'Jersey', 'Holstein Friesian (HF)', 'Sahiwal', 'Kankrej', 'Gir / Gyr', 'Red Sindhi'].index(cow_info[1]))
|
| 150 |
new_age = st.number_input("Enter New Age (in years)", min_value=0, value=cow_info[2])
|
| 151 |
new_tag_id = st.text_input("Enter New Tag ID", value=cow_info[3])
|
|
|
|
| 164 |
|
| 165 |
new_previous_illness = st.selectbox("Previous Illness", ['No', 'Yes'], index=['No', 'Yes'].index(cow_info[4].split('\n')[2].split(": ")[1]))
|
| 166 |
new_previous_diseases = []
|
| 167 |
+
|
| 168 |
+
# Fixing the Previous Disease selection
|
| 169 |
if new_previous_illness == 'Yes':
|
| 170 |
existing_previous_diseases = cow_info[4].split('\n')[2].split(": ")[1]
|
| 171 |
+
# Ensure the values passed as default are part of the available diseases list
|
| 172 |
existing_previous_diseases = existing_previous_diseases.split(", ") if existing_previous_diseases != 'None' else []
|
| 173 |
+
# Only provide valid options that exist in the disease list
|
| 174 |
+
new_previous_diseases = st.multiselect("Select Previous Disease(s)", list(disease_points.keys()), default=[disease for disease in existing_previous_diseases if disease in disease_points.keys()])
|
| 175 |
|
| 176 |
# Reproductive Status handling (as string)
|
| 177 |
reproductive_status_list = ['Not Applicable', 'Estrus Period', 'Gestation Period', 'Adult/Milking Stage', 'Pregnant/Calving Stage']
|