Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -103,7 +103,16 @@ def serialize_patient(patient: dict) -> dict:
|
|
| 103 |
return patient_copy
|
| 104 |
|
| 105 |
def compute_patient_data_hash(data: dict) -> str:
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
return hashlib.sha256(serialized.encode()).hexdigest()
|
| 108 |
|
| 109 |
def compute_file_content_hash(file_content: bytes) -> str:
|
|
|
|
| 103 |
return patient_copy
|
| 104 |
|
| 105 |
def compute_patient_data_hash(data: dict) -> str:
|
| 106 |
+
# Custom JSON encoder to handle datetime objects
|
| 107 |
+
class DateTimeEncoder(json.JSONEncoder):
|
| 108 |
+
def default(self, obj):
|
| 109 |
+
if isinstance(obj, datetime):
|
| 110 |
+
return obj.isoformat()
|
| 111 |
+
elif isinstance(obj, ObjectId):
|
| 112 |
+
return str(obj)
|
| 113 |
+
return super().default(obj)
|
| 114 |
+
|
| 115 |
+
serialized = json.dumps(data, sort_keys=True, cls=DateTimeEncoder)
|
| 116 |
return hashlib.sha256(serialized.encode()).hexdigest()
|
| 117 |
|
| 118 |
def compute_file_content_hash(file_content: bytes) -> str:
|