Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import streamlit as st
|
3 |
+
import chromadb
|
4 |
+
from chromadb import Client
|
5 |
+
from chromadb.config import Settings
|
6 |
+
|
7 |
+
# Initialize ChromaDB client
|
8 |
+
client = Client(Settings(chroma_db_impl="duckdb+parquet", persist_directory="chroma_db"))
|
9 |
+
|
10 |
+
# Create collections for patient reports and daily habits
|
11 |
+
reports_collection = client.create_collection("patient_reports")
|
12 |
+
habits_collection = client.create_collection("daily_habits")
|
13 |
+
|
14 |
+
# Streamlit app layout
|
15 |
+
st.title("Patient Report and Daily Habits Tracker")
|
16 |
+
|
17 |
+
# Input form for patient reports
|
18 |
+
with st.form("patient_report_form"):
|
19 |
+
patient_name = st.text_input("Patient Name")
|
20 |
+
report_date = st.date_input("Report Date")
|
21 |
+
report_text = st.text_area("Report Text")
|
22 |
+
submitted = st.form_submit_button("Submit Report")
|
23 |
+
|
24 |
+
if submitted:
|
25 |
+
reports_collection.add(
|
26 |
+
documents=[report_text],
|
27 |
+
metadatas=[{"patient_name": patient_name, "report_date": str(report_date)}],
|
28 |
+
ids=[f"report_{len(reports_collection.documents) + 1}"]
|
29 |
+
)
|
30 |
+
st.success("Report submitted successfully!")
|
31 |
+
|
32 |
+
# Input form for daily habits
|
33 |
+
with st.form("daily_habit_form"):
|
34 |
+
patient_name_habit = st.text_input("Patient Name for Habit")
|
35 |
+
date_habit = st.date_input("Date for Habit")
|
36 |
+
habit = st.text_input("Habit Description")
|
37 |
+
submitted_habit = st.form_submit_button("Submit Habit")
|
38 |
+
|
39 |
+
if submitted_habit:
|
40 |
+
habits_collection.add(
|
41 |
+
documents=[habit],
|
42 |
+
metadatas=[{"patient_name": patient_name_habit, "date": str(date_habit)}],
|
43 |
+
ids=[f"habit_{len(habits_collection.documents) + 1}"]
|
44 |
+
)
|
45 |
+
st.success("Habit submitted successfully!")
|
46 |
+
|
47 |
+
# Function to display reports
|
48 |
+
if st.button("View Reports"):
|
49 |
+
reports = reports_collection.get()
|
50 |
+
st.write(reports)
|
51 |
+
|
52 |
+
# Function to display habits
|
53 |
+
if st.button("View Habits"):
|
54 |
+
habits = habits_collection.get()
|
55 |
+
st.write(habits)
|