File size: 1,381 Bytes
7273548
4145921
7273548
4145921
 
 
 
7273548
4145921
 
 
 
 
 
 
 
7273548
4145921
 
 
7273548
4145921
 
7273548
4145921
 
 
 
 
 
 
 
 
 
7273548
4145921
 
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
import streamlit as st
import requests

# Function to fetch medicine information from OpenFDA API
def get_medicine_info(medicine_name):
    url = f"https://api.fda.gov/drug/label.json?search=openfda.brand_name:{medicine_name}&limit=1"
    response = requests.get(url)

    if response.status_code == 200:
        data = response.json()
        if "results" in data:
            result = data["results"][0]
            purpose = result.get("purpose", ["No purpose information available"])[0]
            indications = result.get("indications_and_usage", ["No usage information available"])[0]
            return purpose, indications
    return None, None

# Streamlit UI
st.title("Global Medicine Information Lookup")
st.write("Enter a medicine name to get real-time information from OpenFDA.")

# User input
medicine_name = st.text_input("Enter Medicine Name", "").strip()

# Fetch and display information
if st.button("Search"):
    if medicine_name:
        purpose, indications = get_medicine_info(medicine_name)
        if purpose or indications:
            st.subheader(f"Information about {medicine_name}:")
            st.write(f"**Purpose:** {purpose}")
            st.write(f"**Used for:** {indications}")
        else:
            st.warning("Medicine not found in the OpenFDA database. Try another name.")
    else:
        st.warning("Please enter a medicine name.")