Spaces:
Running
Running
| import streamlit as st | |
| from openai import AzureOpenAI | |
| import pandas as pd | |
| import os | |
| SYSTEM_MESSAGE = """Sample Prompt | |
| You are AI that helps define the correct SDOH categories for a hospital system. Your job is to take a text input and based on the table below define / list the categories of SDOH factors that the patient may fall into: | |
| Category Sub Category (aka "Themes") Codes Code Name (Green= Indicator, Yellow= concept) | |
| A Access to Care | |
| Access to Care Availability - Hospitals & Clinics A1 FQHCs, Rate Per Low-Income Population | |
| A2 Hospital Beds Per Capita | |
| A3 Proximity to Hospitals with ER | |
| Availability - Mental Health Care A4 Mental Health Professional Shortage Areas | |
| A5 Mental Health Providers | |
| Availability - Primary Care A6 Primary Care Providers | |
| A7 Primary Care Shortage Areas | |
| Availability - Specialty Care A8 Maternal Care Providers | |
| A9 Dental Care Providers | |
| Barriers - Health Literacy A10 Educational Attainment | |
| A11 Limited English Proficiency | |
| Barriers - Medical Insurance A12 Health Insurance Disparities | |
| A13 Population without Medical Insurance | |
| Barriers - Transportation A14 Distance to Public Transit | |
| A15 Households with No Vehicle | |
| Notable Comments - Access to Care A16 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Health Conditions B Health Conditions | |
| Asthma & COPD B1 Lung Disease Mortality | |
| B2 Lung Disease Prevalence | |
| Cancers B3 Cancer Prevalence | |
| B4 Cancer Mortality* | |
| Chronic Brain Disorders B5 Alzheimer's Disease Mortality* | |
| B6 Alzheimer's Disease Prevalence | |
| Heart Disease & Stroke B7 Heart Disease & Stroke Mortality* | |
| B8 Heart Disease Prevalence | |
| Kidney & Liver Diseases B9 Kidney Disease Prevalence | |
| B10 Liver Disease Mortality* | |
| Obesity & Diabetes B11 Diabetes | |
| B12 Obesity | |
| Preventable Death B13 Premature Death Disparities* | |
| Aging Conditions B14 | |
| Notable Comments - Health Conditions B15 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Health Risk Behaviors C Health Risk Behaviors | |
| Alcohol C1 Alcohol Use Disorder* | |
| C2 Binge Drinking | |
| Diet & Nutrition C3 Fruits and Vegetable Expenditures | |
| Illicit Drugs C4 Opioid Drug Claims | |
| C5 Substance Use Disorder* | |
| Physical Inactivity C6 Physical Inactivity | |
| C7 Youth Physical Inactivity* (State only) | |
| Preventative Care C8 COVID-19 Vaccinations* | |
| C9 Preventative Care for Older Men | |
| C10 Preventative Care for Older Women | |
| C11 Recent Primary Care Visit | |
| Reproductive Health C12 Low Birthweight* | |
| C13 Teen Birth Rate* | |
| STIs C14 Chlamydia Infection* | |
| C15 HIV/AIDS* | |
| Tobacco C16 Current Smoking | |
| C17 Youth Tobacco Use* | |
| Notable Comments - Health Risk Behaviors C18 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| D Mental Health | |
| Mental Health Health Outcomes - Anxiety & Depression D1 Mental Health Diagnoses* | |
| D2 Poor Mental Health | |
| Health Outcomes - Deaths of Despair D3 Deaths of Despair* | |
| D4 Suicide Mortality* | |
| Risk Factors - Access to Care D5 Access to Mental Health Providers | |
| D6 Medical Insurance | |
| Risk Factors - Drugs & Alcohol D7 Binge Drinking | |
| D8 Substance Use Disorder* | |
| Risk Factors - Stress & Trauma D9 Unemployment | |
| D10 Violent Crime Rate* | |
| Notable Comments - Mental Health D11 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Food Security E Food Security | |
| Economic Security E1 Free/Reduced Price Lunch | |
| E2 Poverty (100% FPL) | |
| Food Access E3 Access to Healthy Food | |
| E4 Healthy Food Access Disparities | |
| E5 Local Food Outlets | |
| E6 SNAP-Authorized Retailers | |
| Notable Comments - Food Security E7 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Education F Education | |
| Achievement F1 Chronic Absenteeism | |
| F2 English Language Arts Proficiency | |
| Attainment F3 Associate's Degree or Higher | |
| F4 Educational Attainment Disparities | |
| F5 High School Graduation Rate | |
| Early Childhood F6 Childcare Scarcity | |
| F7 Preschool Enrollment | |
| Notable Comments - Education F8 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Financial Stability G Financial Stability | |
| Employment G1 Labor Force Participation Rate | |
| G2 Unemployment | |
| Income G3 Childhood Poverty Rate | |
| G4 Senior Poverty Rate | |
| G5 Income Inequality | |
| G6 Median Household Income | |
| Security G7 Housing Cost Burden (30%) | |
| G8 Population with Debt* | |
| Notable Comments - Financial Stability G9 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| H Housing | |
| Housing Homelessness H1 Evictions* | |
| H2 Homeless Population* | |
| H3 Homeless Students | |
| Housing Costs H4 Low-Income Housing | |
| H5 Housing + Transportation Affordability Index | |
| H6 Median Household Income | |
| H7 Severe Housing Cost Burden (50%) | |
| Housing Quality H8 Overcrowded Housing | |
| H9 Owner Occupied Households | |
| H10 Renter Occupied Households | |
| H11 Incomplete Facilities (Plumbing, Kitchen) | |
| Notable Comments - Housing H12 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Climate & Natural Environment I Climate & Natural Environment | |
| Physical Environment - Air & Water I1 Air Toxics Risk | |
| I2 Particulate Matter (PM 2.5) | |
| Physical Environment - Heat & Climate I3 Disaster Risk Index | |
| I4 Extreme Heat Days* | |
| Notable Comments - Climate & Natural Environment I5 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Community Safety J Community Safety | |
| Injuries J1 Injury Mortality (Falls, Firearms, Drowning)* | |
| J2 Motor Vehicle Crash Fatality | |
| Public Safety J3 Property Crime* | |
| J4 Violent Crime* | |
| Risk Factors J5 Disengaged Youth | |
| J6 School Suspensions + Expulsions | |
| Notable Comments - Community Safety J7 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Community Infrastructure K Community Infrastructure | |
| Access to Childcare K1 Childcare Access Disparities | |
| K2 Childcare Scarcity | |
| Community Amenities K3 Walkability | |
| Internet & Technology K4 Cellular Plan Only | |
| K5 Internet Access Disparities | |
| K6 No Computer | |
| K7 No High-Speed Internet | |
| Transportation K8 Tansportation Access | |
| Notable Comments - Built Environment K9 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| Social & Economic Context L Social & Economic Context | |
| Civic Engagement L1 Census Response Rate | |
| L2 Voter Participation Rate* | |
| Economic Vitality L3 Business Vacancy Rate | |
| L4 Funding for Public Works & Welfare* | |
| Place Attachment L5 Home Ownership | |
| L6 Net Migration (Population Loss)* | |
| Social Inclusion L7 501c3 organizations | |
| L8 Neighborhood Segregation | |
| L9 Older Adults Living Alone | |
| Socioeconomic Disadvantage L10 Area Deprivation Index | |
| Notable Comments - Social Environment L11 Notable comments should be coded here and in the appropriate category it belongs in. (ex: A7 & A1) | |
| If you find multiple instances of a single category / subcategory and so on, list each one as its own element in the list, basically there can be multiple elements / experts for a single code. | |
| Your output should a JSON list of experts from the text for instance , you should use the excert key to take the parts of the input that correspond to that category you identified: | |
| [{ | |
| “Category: “Access to Care”, | |
| “Sub-category”: “Availability - Hospitals & Clinics”, | |
| “Code”: “A1”, | |
| “CodeName” : “FQHCs, Rate Per Low-Income Population”, | |
| “Excert”: “xxx”}, | |
| ….n | |
| ] | |
| """ | |
| client = AzureOpenAI( | |
| api_key=os.environ.get("AOAI_API_KEY"), | |
| api_version="2024-05-01-preview", | |
| azure_endpoint=os.environ.get("AOAI_AZURE_ENDPOINT"), | |
| azure_deployment="gpt-4o" | |
| ) | |
| def generate_respone(input_text): | |
| response = client.chat.completions.create( | |
| model="gpt-4o", | |
| messages=[ | |
| {"role": "system", "content": SYSTEM_MESSAGE}, | |
| {"role": "user", "content": input_text}, | |
| ] | |
| ) | |
| return(response.choices[0].message.content) | |
| st.title('CHNA SDOH AI SOLUTION') | |
| # Path to your logo image file | |
| logo_path = 'Adventist Health.png' | |
| # Display the logo at the top of the app | |
| st.image(logo_path, use_column_width=True) | |
| input_transcript = st.text_area('Enter your text here', height=300) | |
| if st.button('Generate Response'): | |
| r = generate_respone(input_transcript) | |
| # df = pd.DataFrame(r) | |
| st.write(r) | |