neerajkalyank commited on
Commit
01ac39a
1 Parent(s): c88ed1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -39
app.py CHANGED
@@ -62,25 +62,9 @@ def registration_interface(name, father_name, age, phone, address, pincode):
62
  save_data(patients, last_sequence)
63
  return f"Patient Registered. Patient ID: {patient_id}", patient_id
64
 
65
- # Tests Selection Tab
66
- def test_interface(categories):
67
- available_tests = get_tests_by_category(categories)
68
- return gr.update(choices=available_tests) # Update dropdown with available tests
69
-
70
- def confirm_tests_interface(patient_id, selected_tests):
71
- patients, last_sequence = load_data() # Load both patients and last_sequence
72
- response = select_tests(patient_id, selected_tests, patients) # Update patients directly
73
- save_data(patients, last_sequence) # Save both patients and last_sequence
74
- return response
75
-
76
- # Billing Tab
77
- def billing_interface(patient_id):
78
- patients, _ = load_data() # Load patients and ignore last_sequence
79
- if patient_id in patients:
80
- billing_info = fetch_billing(patient_id, patients)
81
- return billing_info
82
- else:
83
- return "Invalid Patient ID. Please check the ID."
84
 
85
  # Gradio Interface
86
  with gr.Blocks() as app:
@@ -96,28 +80,24 @@ with gr.Blocks() as app:
96
  with gr.Row():
97
  address = gr.Textbox(label="Address", placeholder="Enter address", lines=2)
98
  pincode = gr.Number(label="Pincode", value=None, elem_id="pincode_field")
 
99
  register_button = gr.Button("Register Patient")
100
  registration_output = gr.Textbox(label="Registration Output")
101
- hidden_patient_id = gr.Textbox(visible=False, elem_id="hidden_patient_id") # Hidden field to store the patient ID
102
-
103
- register_button.click(registration_interface, [name, father_name, age, phone, address, pincode], [registration_output, hidden_patient_id])
104
-
105
- # Custom HTML for Copy ID Button
106
- gr.HTML("""
107
- <div style="margin-top: 10px;">
108
- <button onclick="copyPatientID()" style="background-color: #3b74f2; color: white; padding: 10px; border-radius: 5px; border: none; cursor: pointer;">Copy Patient ID</button>
109
- <script>
110
- function copyPatientID() {
111
- const patientID = document.querySelector('[aria-label="hidden_patient_id"] textarea').value;
112
- navigator.clipboard.writeText(patientID).then(() => {
113
- alert('Patient ID copied to clipboard');
114
- }).catch(err => {
115
- alert('Failed to copy Patient ID');
116
- });
117
- }
118
- </script>
119
- </div>
120
- """)
121
 
122
  with gr.Tab("Tests"):
123
  patient_id_test = gr.Textbox(label="Patient ID")
 
62
  save_data(patients, last_sequence)
63
  return f"Patient Registered. Patient ID: {patient_id}", patient_id
64
 
65
+ # Copy functionality
66
+ def copy_patient_id(patient_id):
67
+ return f"{patient_id} copied to clipboard!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  # Gradio Interface
70
  with gr.Blocks() as app:
 
80
  with gr.Row():
81
  address = gr.Textbox(label="Address", placeholder="Enter address", lines=2)
82
  pincode = gr.Number(label="Pincode", value=None, elem_id="pincode_field")
83
+
84
  register_button = gr.Button("Register Patient")
85
  registration_output = gr.Textbox(label="Registration Output")
86
+ patient_id_display = gr.Textbox(label="Patient ID", interactive=False) # Display Patient ID here
87
+ copy_button = gr.Button("Copy Patient ID")
88
+ copy_output = gr.Textbox(label="Copy Status", interactive=False)
89
+
90
+ register_button.click(
91
+ registration_interface,
92
+ [name, father_name, age, phone, address, pincode],
93
+ [registration_output, patient_id_display]
94
+ )
95
+
96
+ copy_button.click(
97
+ copy_patient_id,
98
+ [patient_id_display], # Pass the Patient ID to the function
99
+ copy_output
100
+ )
 
 
 
 
 
101
 
102
  with gr.Tab("Tests"):
103
  patient_id_test = gr.Textbox(label="Patient ID")