mustafa2ak commited on
Commit
92a6999
·
verified ·
1 Parent(s): 27d20b1

Update health_module.py

Browse files
Files changed (1) hide show
  1. health_module.py +51 -0
health_module.py CHANGED
@@ -216,6 +216,57 @@ class DogHealthAssessment:
216
  scores['visible_issues'] = 7.0
217
 
218
  return scores
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
  def assess_movement(self, dog_id: int, current_pos: Tuple[float, float]) -> float:
221
  """
 
216
  scores['visible_issues'] = 7.0
217
 
218
  return scores
219
+ # database_health_update.py
220
+ """Add health assessment fields to existing database"""
221
+
222
+ def add_health_fields_to_database():
223
+ """Add health-related fields to the database"""
224
+ import sqlite3
225
+ from pathlib import Path
226
+
227
+ db_path = "dog_monitoring.db"
228
+
229
+ # Only proceed if database exists
230
+ if not Path(db_path).exists():
231
+ return
232
+
233
+ conn = sqlite3.connect(db_path)
234
+ cursor = conn.cursor()
235
+
236
+ # Add health fields to dogs table
237
+ try:
238
+ cursor.execute("ALTER TABLE dogs ADD COLUMN last_health_score REAL DEFAULT 5.0")
239
+ except:
240
+ pass # Column already exists
241
+
242
+ try:
243
+ cursor.execute("ALTER TABLE dogs ADD COLUMN health_status TEXT DEFAULT 'Unknown'")
244
+ except:
245
+ pass # Column already exists
246
+
247
+ # Create health assessments table if not exists
248
+ cursor.execute("""
249
+ CREATE TABLE IF NOT EXISTS health_assessments (
250
+ assessment_id INTEGER PRIMARY KEY AUTOINCREMENT,
251
+ dog_id INTEGER,
252
+ timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
253
+ health_score REAL,
254
+ status TEXT,
255
+ posture_score REAL,
256
+ gait_score REAL,
257
+ body_condition_score REAL,
258
+ activity_score REAL,
259
+ alerts TEXT,
260
+ recommendations TEXT,
261
+ confidence REAL,
262
+ video_source TEXT,
263
+ frame_number INTEGER,
264
+ FOREIGN KEY (dog_id) REFERENCES dogs(dog_id)
265
+ )
266
+ """)
267
+
268
+ conn.commit()
269
+ conn.close()
270
 
271
  def assess_movement(self, dog_id: int, current_pos: Tuple[float, float]) -> float:
272
  """