File size: 4,234 Bytes
9270f6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
daf7dea
 
9270f6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
daf7dea
9270f6b
 
 
deb89a3
9270f6b
 
 
 
deb89a3
 
 
 
 
 
 
 
 
 
9270f6b
 
deb89a3
9270f6b
 
deb89a3
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import gradio as gr
from service import GPT_Service, Stage

# Define the function to be called when the button is clicked
def process_text(keywords, stage, medical_history):
    if(keywords.strip()!='' and stage!=None and len(stage)!=0):
        try:
            gptService=GPT_Service()
            if stage == Stage.INITIAL_ASSESSMENT.value:
                return gptService.getInitialAssessment(keywords,medical_history)
            elif stage == Stage.FOLLOWUP_ASSESSMENT.value:
                return gptService.getFollowUpAssessment(keywords,medical_history)
            elif stage == Stage.EVALUATION.value:
                return gptService.getEvaluation(keywords,medical_history)
            elif stage == Stage.DETAILED_EVALUATION.value:
                return gptService.getDetailedEvaluation(keywords,medical_history)
            elif stage == Stage.PROGRESS_NOTE.value:
                return gptService.getProgressNote(keywords,medical_history)
            elif stage == Stage.DISCHARGE_SUMMARY.value:
                return gptService.getDischargeSummary(keywords,medical_history)
            elif stage == Stage.SHORT_TERM_GOALS.value:
                return gptService.getShortTermGoals(keywords,medical_history)
            elif stage == Stage.LONG_TERM_GOALS.value:
                return gptService.getLongTermGoals(keywords,medical_history)
            elif stage == Stage.RECOMMENDATION.value:
                return gptService.getRecommendation(keywords,medical_history)
            else:
                print("Unknown stage")
                raise gr.Error('Unknown stage encountered')
        except:
            print("GPT error encounters")
            raise gr.Error('Something went wrong please try again')
    else:
        print("Unknown stage parameters")
        raise gr.Error('Provide appropriate parameters and try again')
    

# Create text input components with labels
input_text = gr.Textbox(lines=7, label="Sample keywords", placeholder="Enter sample keywords here")
medical_history = gr.Textbox(lines=7, label="Medical History", placeholder="Enter medical history here")

# Populating stage choices and creating dropdown component with label

# To add all the stages
# stage_choices = [stage.value for stage in Stage]

# To add few stages
stage_choices = [Stage.INITIAL_ASSESSMENT.value,Stage.SHORT_TERM_GOALS.value,Stage.LONG_TERM_GOALS.value, Stage.RECOMMENDATION.value]

stage = gr.Dropdown(choices=stage_choices, label="Stage")

# Create output containers
output_text_1 = gr.Textbox(lines=6, label="Variant 1", show_copy_button=True)
output_text_2 = gr.Textbox(lines=6, label="Variant 2", show_copy_button=True)
output_text_3 = gr.Textbox(lines=6, label="Variant 3", show_copy_button=True)

title_html = """
<div style="display: flex; align-items: center; width=100%; background-color:#FFC90E; overflow:auto;">
    <img src='https://i.ibb.co/gPFskvg/LOGO-1.png' style='height: 90px; width:90px; margin-left: 20px;'>
    <span style="margin-left: 20px;font-size:30px">
        <span>Patient Assessment Documentation &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </span>
</div>

"""


# Create a Gradio interface
interface=gr.Interface(fn=process_text,
             inputs=[input_text, stage, medical_history],
             outputs=[output_text_1,output_text_2,output_text_3],
             title=title_html,
             theme=gr.themes.Default(),
             allow_flagging='never')

interface.launch()