| """ |
| Clinical Action and Recommendation Engine. |
| Generates targeted lifestyle and follow-up care steps based on patient risk attributions. |
| """ |
|
|
|
|
| class MedicalRecommendationEngine: |
| def __init__(self): |
| pass |
|
|
| def generate_patient_guidelines(self, risk_category_string, attribution_dataframe): |
| """ |
| Generates actionable care steps tailored to the patient's top risk contributors. |
| """ |
| care_guidelines = [] |
|
|
| |
| if "Severe" in risk_category_string: |
| care_guidelines.append("Cardiovascular specialist review advised immediately.") |
| care_guidelines.append("Monitor blood pressure and vital signs regularly.") |
| elif "Moderate" in risk_category_string: |
| care_guidelines.append("Schedule a follow-up clinical review within 14 business days.") |
| care_guidelines.append("Begin systematic tracking of daily vitals.") |
| else: |
| care_guidelines.append("Maintain routine annual check-ups as scheduled.") |
|
|
| |
| if not attribution_dataframe.empty and "Impact_Percentage" in attribution_dataframe.columns: |
| sorted_features = attribution_dataframe.sort_values(by="Impact_Percentage", ascending=False) |
| top_contributors = sorted_features["Feature"].head(2).tolist() |
|
|
| for feature_name in top_contributors: |
| if feature_name == "HighBP": |
| care_guidelines.append("Initiate a low-sodium dietary plan and track blood pressure daily.") |
| elif feature_name == "BMI": |
| care_guidelines.append("Discuss a supervised weight management and exercise plan.") |
| elif feature_name == "Smoker": |
| care_guidelines.append("Provide resources for smoking cessation and tobacco alternatives.") |
|
|
| |
| if not care_guidelines: |
| care_guidelines.append("Consult with your primary care physician for personalized health planning.") |
|
|
| return care_guidelines |
|
|
|
|
| if __name__ == "__main__": |
| import pandas as pd |
|
|
| mock_attributions = pd.DataFrame({ |
| "Feature": ["HighBP", "BMI", "Smoker"], |
| "Impact_Percentage": [18.5, 14.2, 2.1] |
| }) |
|
|
| engine = MedicalRecommendationEngine() |
| guidelines_list = engine.generate_patient_guidelines("Severe Cardiovascular Risk", mock_attributions) |
| print("[SUCCESS] Actionable care guidelines generated successfully:") |
| for line in guidelines_list: |
| print(f" • {line}") |