# Project export: Medisync

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: TreeHacks 2024
- Tagline: Millions of users fill out health care forms everyday. Medisync fills out your forms with data that you have securely inputted. Saving you and hospitals time.
- Devpost: https://devpost.com/software/medisync-iytmez
- GitHub: https://github.com/BGGB1/TREEHACKS
- Video: https://www.youtube.com/embed/VdJfFUj5XWM?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 2 GitHub contributor(s) — Benjamin Bonas (20 commits), laithgordon (2 commits)

## Devpost submission (written by the team)

### Inspiration

The inspiration behind Medisync came from observing the extensive time patients and medical staff spend on filling out and processing medical forms. We noticed a significant delay in treatment initiation due to this paperwork. Our goal was to streamline this process, making healthcare more efficient and accessible by leveraging the power of AI. We envisioned a solution that not only saves time but also minimizes errors in patient data, leading to better patient outcomes.

### What it does

Medisync uses AI algorithms to automate the process of filling out medical forms. Patients can speak or type their information into the app, which then intelligently categorizes and inputs the data into the necessary forms. The patient's data will be continually updated with future questions as their medical history progresses. All data will be securely stored on the user's local machine. The user will be able to quickly and securely input their medical data into forms with different formats from different institutions. This results in a faster, more efficient onboarding process for patients.

### How we built it

We built Medisync using Natural Language Processing (NLP). Our development stack includes Python for backend development. We modeled a user-friendly interface that simplifies the data entry process. We uploaded common medical forms from the internet, we then scraped them for information and then using Open Ai's API call we populated the form outputting the final result in an md file.

### Challenges we ran into

Some challenges we faced were parsing the forms correctly and breaking down the questions into the relevant health categories. The output of the program was dependent on the level of understanding of the data that was available to fill the forms. Thus, in depth question generation was a challenge we had to overcome. We also had to understand how our project can be HIPAA compliant so that it can be released to the end user. Medical data is highly sensitive and personal and there are lots of privacy laws to product individuals. Going forward we have a detailed plan on how to make our service HIPAA compliant.

### Accomplishments we're proud of

We are proud of developing a functional prototype that demonstrates a significant reduction in time spent on medical paperwork. Our pilot tests on random users showed a 70% decrease in patient onboarding time. Receiving positive feedback from patients. Furthermore, there is a huge issue surrounding human error in these forms. As they are repetitive long-form tasks it is easy for people to make a mistake. We are very proud to have made a product that makes patients safer and healthier by reducing error in medical forms.

### What we learned

Throughout this project, we learned the importance of interdisciplinary collaboration, combining expertise in AI, software development, and healthcare to address a common challenge. We gained insights into the complexities of healthcare regulations and the critical role of data privacy. This project also honed our skills in AI and ML, particularly in applying NLP techniques to real-world problems. Overall we have learnt the importance of solving a complex problem from many angles to create a solution in a time efficient manner. Combining new and old skills in a highly effective way.

### What's next

Moving forward, we plan to make sure that Medisync fully meets HIPAA compliance and test our service with many more users. We are also exploring partnerships with hospitals and healthcare systems to integrate our solution into their existing workflows. Additionally, we aim to incorporate AI-driven analytics to provide healthcare providers with insights into patient data, further enhancing the quality of care. Allowing our service to fill out more forms faster. We also hope to improve the user experience and workflow of inputting user data by highlighting missing information from forms that users have filled out. In this we will make sure that we gather the right data in the fewest questions and thus in the most efficient way for our end user.

## README (from the GitHub repository)

No README available.

## Detected evidence (automated analysis)

Indexed codebase: 3 recognized source files, 11 KB.
- Python (language) — detected in the code
- OpenAI (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (9 of 9)

```
ConvertPDF
CSV_write
filled_out.txt
FilledOutForm.md
FormPopulator
MedicalData.txt
output_final.md
Project1.ipynb
Setup.py
```

### Dependencies

No dependency index available.

### Recent commits (newest first)

- Created using Colab
- Add files via upload
- Add files via upload
- Add files via upload
- Delete responses.csv
- Delete responses
- Delete MedicatData.txt
- Delete CSV_write
- Delete ConvertPDF
- Delete Data
- Delete info_form
- Delete Testing API
- Delete Testing api call
- Delete .gitattributes
- Add files via upload
- kljjlk
- hhkjhkjhkj
- Add files via upload
- Add files via upload
- Add files via upload

## Key source files (fetched from GitHub, selected and truncated for size)

### FilledOutForm.md

```markdown
Patient Name: Laith Gordon 
 
What brings you in today? Fever, cough, nausea, and eye dryness  
What do you prefer to be called (nickname)? Laith 
 
Please list all of your medical conditions. 
1. Celiacs   2. Arthuritis  
 
What surgical or medical procedures have you had in the past? 
1. Acl repair   2. Heart stent   3. Gastric bypass  
 
Please tell us about medical conditions in your family including cancer, diabetes, heart disease, etc., and at what age they developed the disease: 
Mother: Diabetes, Age developed: unknown  
Father: High cholesterol, Age developed: unknown  
 
What medications, herbs, and vitamins/supplements are you currently taking? Remember to include over-the-counter medicines. Please include the doses and how often you take each one. 
1. Advil (dose and frequency unknown)  
Vitamin C (dose and frequency unknown)  
 
Allergies? ☑ Yes  
If “yes”, reactions? Pollen  
 
Social History:  
Relationship status: ☐ Married/Partner ☑ Single ☐ Divorced ☐ Widowed  
Preferred sexual partner: ☑ Men ☐ Women ☐ Both ☐ Never sexually active  
Currently sexually active: ☑ No  
Have you ever been pregnant: ☐ Yes ☑ No How many times? 0  
Do you have children? ☐ Yes ☑ No How many? 0  
 
Who lives with you at home? Nobody  
Do you feel safe at home and in your current relationship? ☑ Yes  
What is your occupation? Student  
What (if any) physical activity/exercise do you engage in and how often? Twice a week  
How would you describe your dietary intake? Healthy  
How much alcohol do you drink? Information not provided  
Do you smoke? ☐ Now ☐ Past ☑ Never  
Have you ever had a blood transfusion? ☑ Yes  
How often have you noticed the following emotions over the last two weeks: Information not provided  
 
Review of Systems: Please check if you are currently having any of the following symptoms.  
Constitutional  
☑ Fever  
Eyes  
☐ Blurred vision  
Respiratory  
☑ Cough  
Gastrointestinal  
☑ Nausea/vomiting  
Skin  
☐ Rash  
Endocrinologic  
☑ Excessive thirst  
Hematologic  
☐ Abnormal bleeding/bruising  
 
Health Maintenance/Prevention  
Please specify if and when you received the following services. (Incomplete)  
☑ Influenza (flu) vaccine Date: 2003  
Tetanus vaccine Date: 2005  
Hepatitis A vaccine Date: 2004  
Hepatitis B vaccine Date: 2015  
Varicella vaccine Date: 2010  
```

### output_final.md

```markdown
COMPREHENSIVE  NEW PATIENT QUESTIONNAIRE 
UCLA Form #520200   Rev. (7/15)                                                                                                                                                                                                    Page 1 of 5 MRN: 
 
Patient Name: sophia Malaekeh 
 
(Patient Label) 
 
What brings you in today?  MENTAL HEALTH ISSUES 
 
 What do you prefer to be called (nickname)? SOPHIE 
 
Please list all of your medical conditions. 
1. 
2. 
3. 
4. 
5. 
6. 
7. 
8. 
 
What surgical or medical procedures have you had in the past? 
1. 
2. 
3. 
4. 
5. 
6. 
 
Please tell us about medical conditions in your family including cancer, diabetes, heart 
disease, etc., and at what age they developed the disease: 
Mother: Age:  
Father: Age:  
Siblings: Age:  
Others: Age:  
What medications, herbs, and vitamins/supplements are you currently taking? Remember 
to include over-the-counter medicines. Please include the doses and how often you take 
each one. 
1. OZEMPIC  
2.  
3.  
4.  
5.  
6.  
7.  
8.  
9.  
10.  

Allergies?   Yes     No  
If “yes,” reactions? GLUTEN 
 
Social History: 
Relationship status:      Married/Partner       Single       Divorced        Widowed 
Preferred sexual partner:    Men  Women       Both      Never sexually active 
Currently sexually active:    Yes     No  
Have you ever been pregnant:     Yes     No  How many times?  
Do you have children?   Yes     No   How many?  
 
COMPREHENSIVE  NEW PATIENT QUESTIONNAIRE 
UCLA Form #520200   Rev. (7/15)                                                                                                                                                                                                    Page 2 of 5 MRN: 
 
Patient Name: sophia Malaekeh 
 
(Patient Label) 
Who lives with you at home?  
Do you feel safe at home and in your current relationship?   Yes    No  
What is your occupation?  
What (if any) physical activity/exercise do you engage in and how often?  
How would you describe your dietary intake?  
How much alcohol do you drink? per day   per week 
If yes, how many times in the past month have you had more than 4 alcoholic drinks in one day?  
Do you smoke?    Now     Past    Never   
If so, how many per day and for how  long?  
Have you ever had a blood transfusion?       Yes     No      
How often have you noticed the following emotions over the last two weeks: (check the answer that 
best describes how you feel)
Little interest in 
doing things  None   Several         days  More than half the days  Nearly every day 
Feeling down or depressed  None   Several        days  More than half the days  Nearly every day 
 
Review of Systems: Please check if you are currently having any of the following symptoms. 
Constitutional 
 Fever 
 Night sweats  Weight loss  Fatigue  Excessive sleepiness/      Insomnia  
Eyes 
 Blurred vision 
 Double vision  Eye pain  Eye dryness  Respiratory 
 Cou
[truncated — 3204 more characters]
```

### Setup.py

```python
## This program prompts the user to enter their medical data. It then prepares it in a format ready for their data to be used to fill out a form.
import openai
import re

# Your OpenAI API key
openai.api_key = 'insert-api-key-here'

def initialPrompt(numQuestions):
    questioningOver = False
    # Start the conversation with a series of questions
    prompt = "You will create a text file of medical records. Output an text array of " + numQuestions + " new questions written in the format ['question 1', 'question 2', 'question 3', ... , 'questions" + numQuestions + "], do not respond anything else other than these questions stored in square brackets and each separated by a comma, the questions themselves must not contain commas - the commas should only come in between questions. The first question should be what is your name."
    full_prompt = [ {"role": "system", "content": prompt} ]
    # Send the initial prompt to the API
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=full_prompt
    )
    # Store the answers
    generatedQuestions = response.choices[0].message.content

    # Remove the brackets at the beginning and the end
    stripped_string = generatedQuestions.strip("[]")

    # Use regex to split the string by comma, accounting for potential spaces
    questions = re.split(r'\s*,\s*', stripped_string)
    return questions

def processData(questions):
    answers = []

    for question in questions:
        print(question)
        response = input()
        answers.append(response)
    return answers

if __name__ == "__main__":
    ## response is the first set of questions
    print("How many questions do you want to answer?")
    numQuestions = input()
    questions = initialPrompt(numQuestions)

    ## answers is answers the user provides
    answers = processData(questions)

    with open('openai-env/Code/MedicalData.txt', 'w') as file:
        for question, answer in zip(questions, answers):
            file.write(f"{question}: {answer}\n")
    
    
```