neerajkalyank commited on
Commit
1a70d1e
1 Parent(s): 977854e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -19
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  import json
3
  from datetime import datetime
@@ -6,19 +8,6 @@ from test_selection import select_tests, get_tests_by_category
6
  from billing import fetch_billing
7
 
8
  # Load data
9
- def load_data():
10
- try:
11
- with open("data.json", "r") as file:
12
- return json.load(file)
13
- except FileNotFoundError:
14
- return {}
15
-
16
- # Save data
17
- def save_data(data):
18
- with open("data.json", "w") as file:
19
- json.dump(data, file)
20
-
21
- # Load data and last sequence
22
  def load_data():
23
  try:
24
  with open("data.json", "r") as file:
@@ -27,7 +16,7 @@ def load_data():
27
  except FileNotFoundError:
28
  return {}, {"year": None, "month": None, "number": 0}
29
 
30
- # Save data and last sequence
31
  def save_data(patients, last_sequence):
32
  with open("data.json", "w") as file:
33
  json.dump({"patients": patients, "last_sequence": last_sequence}, file)
@@ -54,7 +43,6 @@ def generate_patient_id(phone, last_sequence):
54
 
55
  # Patient Registration Tab
56
  def registration_interface(name, father_name, age, phone, address, pincode):
57
- # Load data and sequence info
58
  patients, last_sequence = load_data()
59
 
60
  # Generate patient ID
@@ -73,7 +61,7 @@ def registration_interface(name, father_name, age, phone, address, pincode):
73
  }
74
 
75
  # Save data and updated sequence
76
- save_data(patients, last_sequence) # Pass both `patients` and `last_sequence`
77
  return f"Patient Registered. Patient ID: {patient_id}"
78
 
79
  # Tests Selection Tab
@@ -87,7 +75,7 @@ def confirm_tests_interface(patient_id, selected_tests):
87
  save_data(patients, last_sequence) # Save both patients and last_sequence
88
  return response
89
 
90
-
91
  def billing_interface(patient_id):
92
  patients, _ = load_data() # Load patients and ignore last_sequence
93
  if patient_id in patients:
@@ -96,7 +84,6 @@ def billing_interface(patient_id):
96
  else:
97
  return "Invalid Patient ID. Please check the ID."
98
 
99
-
100
  # Gradio Interface
101
  with gr.Blocks() as app:
102
  gr.Markdown("# Sathkrutha LIMS - Patient Management and Billing App")
@@ -135,22 +122,84 @@ with gr.Blocks() as app:
135
  billing_output = gr.Textbox(label="Billing Information")
136
  fetch_button.click(billing_interface, [patient_id_bill], billing_output)
137
 
138
- # Custom CSS to adjust field sizes
139
  app.css = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  #name_field, #father_name_field {
141
  max-width: 750px;
 
 
 
142
  }
143
 
144
  #age_field {
145
  max-width: 300px;
 
 
 
146
  }
147
 
148
  #phone_field {
149
  max-width: 1100px;
 
 
 
150
  }
151
 
152
  #pincode_field {
153
  max-width: 400px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
155
  """
156
 
 
1
+ # app.py
2
+
3
  import gradio as gr
4
  import json
5
  from datetime import datetime
 
8
  from billing import fetch_billing
9
 
10
  # Load data
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  def load_data():
12
  try:
13
  with open("data.json", "r") as file:
 
16
  except FileNotFoundError:
17
  return {}, {"year": None, "month": None, "number": 0}
18
 
19
+ # Save data
20
  def save_data(patients, last_sequence):
21
  with open("data.json", "w") as file:
22
  json.dump({"patients": patients, "last_sequence": last_sequence}, file)
 
43
 
44
  # Patient Registration Tab
45
  def registration_interface(name, father_name, age, phone, address, pincode):
 
46
  patients, last_sequence = load_data()
47
 
48
  # Generate patient ID
 
61
  }
62
 
63
  # Save data and updated sequence
64
+ save_data(patients, last_sequence)
65
  return f"Patient Registered. Patient ID: {patient_id}"
66
 
67
  # Tests Selection Tab
 
75
  save_data(patients, last_sequence) # Save both patients and last_sequence
76
  return response
77
 
78
+ # Billing Tab
79
  def billing_interface(patient_id):
80
  patients, _ = load_data() # Load patients and ignore last_sequence
81
  if patient_id in patients:
 
84
  else:
85
  return "Invalid Patient ID. Please check the ID."
86
 
 
87
  # Gradio Interface
88
  with gr.Blocks() as app:
89
  gr.Markdown("# Sathkrutha LIMS - Patient Management and Billing App")
 
122
  billing_output = gr.Textbox(label="Billing Information")
123
  fetch_button.click(billing_interface, [patient_id_bill], billing_output)
124
 
125
+ # Custom CSS styling
126
  app.css = """
127
+ body {
128
+ font-family: Arial, sans-serif;
129
+ background-color: #f5f5f5;
130
+ }
131
+
132
+ .gradio-container {
133
+ max-width: 800px;
134
+ margin: 0 auto;
135
+ padding: 20px;
136
+ background-color: #333;
137
+ border-radius: 10px;
138
+ color: #ffffff;
139
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
140
+ }
141
+
142
  #name_field, #father_name_field {
143
  max-width: 750px;
144
+ border: 1px solid #ddd;
145
+ border-radius: 5px;
146
+ padding: 10px;
147
  }
148
 
149
  #age_field {
150
  max-width: 300px;
151
+ border: 1px solid #ddd;
152
+ border-radius: 5px;
153
+ padding: 10px;
154
  }
155
 
156
  #phone_field {
157
  max-width: 1100px;
158
+ border: 1px solid #ddd;
159
+ border-radius: 5px;
160
+ padding: 10px;
161
  }
162
 
163
  #pincode_field {
164
  max-width: 400px;
165
+ border: 1px solid #ddd;
166
+ border-radius: 5px;
167
+ padding: 10px;
168
+ }
169
+
170
+ textarea {
171
+ font-size: 14px;
172
+ color: #333;
173
+ }
174
+
175
+ .gr-button {
176
+ background-color: #ff5722;
177
+ color: #fff;
178
+ border: none;
179
+ border-radius: 5px;
180
+ padding: 10px 20px;
181
+ cursor: pointer;
182
+ font-weight: bold;
183
+ }
184
+
185
+ .gr-button:hover {
186
+ background-color: #e64a19;
187
+ }
188
+
189
+ .gr-tab {
190
+ background-color: #222;
191
+ border-radius: 8px;
192
+ }
193
+
194
+ h1, h2, h3, h4, h5, h6 {
195
+ color: #ff9800;
196
+ }
197
+
198
+ #billing_output {
199
+ background-color: #444;
200
+ padding: 15px;
201
+ border-radius: 5px;
202
+ color: #fff;
203
  }
204
  """
205