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 = """
Patient Assessment Documentation