File size: 3,078 Bytes
9270f6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252577c
 
9270f6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252577c
9270f6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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')
    
def pasteFunctionality():
    print("Hello word")

# 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 a button component to copy goals
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)


# Create a Gradio interface
gr.Interface(fn=process_text,
             inputs=[input_text, stage, medical_history],
             outputs=[output_text_1,output_text_2,output_text_3],
             title="Medical Model Interface",
             allow_flagging='never').launch()