class ConversationEngine: def generate_response( self, session, state, user_message, ): stage = session.stage if stage == "greeting": return { "message": ( "What brings you to the hospital today?" ), "next_stage": "reason_for_visit", } if stage == "reason_for_visit": return { "message": ( "Can you tell me more about what " "you are experiencing?" ), "next_stage": "symptom_collection", } if stage == "symptom_collection": return { "message": ( "How long have you been experiencing " "this problem?" ), "next_stage": "symptom_details", } if stage == "symptom_details": return { "message": ( "Are you currently taking any " "medications?" ), "next_stage": "medications", } if stage == "medications": return { "message": ( "Do you have any known allergies?" ), "next_stage": "allergies", } if stage == "allergies": return { "message": ( "Thank you. I have collected the " "initial information." ), "next_stage": "summary", } return { "message": ( "Thank you. Let's continue." ), "next_stage": stage, }