File size: 1,897 Bytes
9df0ed1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# app.py
import streamlit as st
import chromadb
from chromadb import Client
from chromadb.config import Settings

# Initialize ChromaDB client
client = Client(Settings(chroma_db_impl="duckdb+parquet", persist_directory="chroma_db"))

# Create collections for patient reports and daily habits
reports_collection = client.create_collection("patient_reports")
habits_collection = client.create_collection("daily_habits")

# Streamlit app layout
st.title("Patient Report and Daily Habits Tracker")

# Input form for patient reports
with st.form("patient_report_form"):
    patient_name = st.text_input("Patient Name")
    report_date = st.date_input("Report Date")
    report_text = st.text_area("Report Text")
    submitted = st.form_submit_button("Submit Report")

    if submitted:
        reports_collection.add(
            documents=[report_text],
            metadatas=[{"patient_name": patient_name, "report_date": str(report_date)}],
            ids=[f"report_{len(reports_collection.documents) + 1}"]
        )
        st.success("Report submitted successfully!")

# Input form for daily habits
with st.form("daily_habit_form"):
    patient_name_habit = st.text_input("Patient Name for Habit")
    date_habit = st.date_input("Date for Habit")
    habit = st.text_input("Habit Description")
    submitted_habit = st.form_submit_button("Submit Habit")

    if submitted_habit:
        habits_collection.add(
            documents=[habit],
            metadatas=[{"patient_name": patient_name_habit, "date": str(date_habit)}],
            ids=[f"habit_{len(habits_collection.documents) + 1}"]
        )
        st.success("Habit submitted successfully!")

# Function to display reports
if st.button("View Reports"):
    reports = reports_collection.get()
    st.write(reports)

# Function to display habits
if st.button("View Habits"):
    habits = habits_collection.get()
    st.write(habits)