Spaces:
Sleeping
Sleeping
| # Click the "Copy" button in the top-right corner of this box. | |
| from services.mock_ehr_service import get_patient_data | |
| from services.mock_ai_service import get_readmission_prediction | |
| import json | |
| def run_patient_risk_analysis(patient_id: str): | |
| """ | |
| Orchestrates the process of fetching patient data and getting a prediction. | |
| """ | |
| print(f"--- [Orchestrator] Starting analysis for patient_id: {patient_id} ---") | |
| # Step 1: Get patient data from the mock EHR service | |
| patient_data = get_patient_data(patient_id) | |
| if not patient_data: | |
| print(f"--- [Orchestrator] Analysis failed: No data found for patient_id {patient_id} ---") | |
| return None | |
| # Step 2: Get a prediction from the mock AI service | |
| prediction_json = get_readmission_prediction(patient_data) | |
| prediction_data = json.loads(prediction_json) # Convert the JSON string to a dictionary | |
| print(f"--- [Orchestrator] Analysis complete for patient_id: {patient_id} ---") | |
| # Step 3: Return the final analysis data | |
| return prediction_data |