|
|
import gradio as gr |
|
|
import csv |
|
|
import os |
|
|
|
|
|
|
|
|
csv_file_path = "registered_patients.csv" |
|
|
|
|
|
|
|
|
if not os.path.exists(csv_file_path): |
|
|
with open(csv_file_path, mode='w', newline='') as file: |
|
|
writer = csv.writer(file) |
|
|
writer.writerow(["Patient Name", "Age", "Contact Number"]) |
|
|
|
|
|
|
|
|
def register_patient(patient_name, age, contact_number): |
|
|
|
|
|
with open(csv_file_path, mode='a', newline='') as file: |
|
|
writer = csv.writer(file) |
|
|
writer.writerow([patient_name, age, contact_number]) |
|
|
return f"Patient {patient_name} registered successfully!" |
|
|
|
|
|
|
|
|
with gr.Blocks() as interface: |
|
|
gr.Markdown("## Patient Registration") |
|
|
|
|
|
with gr.Row(): |
|
|
patient_name = gr.Textbox(label="Patient Name", placeholder="Enter patient name") |
|
|
age = gr.Number(label="Age") |
|
|
contact_number = gr.Textbox(label="Contact Number", placeholder="Enter contact number") |
|
|
|
|
|
output = gr.Textbox(label="Registration Status") |
|
|
|
|
|
register_button = gr.Button("Register") |
|
|
register_button.click(register_patient, inputs=[patient_name, age, contact_number], outputs=output) |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
interface.launch() |
|
|
|