Files
aionboarding/ai-patient-onboarding/app/services/completion_service.py
T

53 lines
1.4 KiB
Python

import json
class CompletionService:
def is_complete(
self,
session,
state,
) -> bool:
data = json.loads(
state.state_json
)
reason = data.get("reason_for_visit")
symptoms = data.get("symptoms")
history = data.get("medical_history")
medications = data.get("medications")
allergies = data.get("allergies")
# Check structured status dictionary format
if isinstance(reason, dict):
if reason.get("status") == "not_collected" or not reason.get("value"):
return False
elif not reason:
return False
if isinstance(symptoms, dict):
if symptoms.get("status") == "not_collected" or len(symptoms.get("items", [])) == 0:
return False
elif not symptoms:
return False
if isinstance(history, dict):
if history.get("status") == "not_collected":
return False
elif history is None:
return False
if isinstance(medications, dict):
if medications.get("status") == "not_collected":
return False
elif medications is None:
return False
if isinstance(allergies, dict):
if allergies.get("status") == "not_collected":
return False
elif allergies is None:
return False
return True