empathy-framework 4.6.6__py3-none-any.whl → 4.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/METADATA +7 -6
- empathy_framework-4.7.0.dist-info/RECORD +354 -0
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/top_level.txt +0 -2
- empathy_healthcare_plugin/monitors/monitoring/__init__.py +9 -9
- empathy_llm_toolkit/agent_factory/__init__.py +6 -6
- empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +7 -10
- empathy_llm_toolkit/agents_md/__init__.py +22 -0
- empathy_llm_toolkit/agents_md/loader.py +218 -0
- empathy_llm_toolkit/agents_md/parser.py +271 -0
- empathy_llm_toolkit/agents_md/registry.py +307 -0
- empathy_llm_toolkit/commands/__init__.py +51 -0
- empathy_llm_toolkit/commands/context.py +375 -0
- empathy_llm_toolkit/commands/loader.py +301 -0
- empathy_llm_toolkit/commands/models.py +231 -0
- empathy_llm_toolkit/commands/parser.py +371 -0
- empathy_llm_toolkit/commands/registry.py +429 -0
- empathy_llm_toolkit/config/__init__.py +8 -8
- empathy_llm_toolkit/config/unified.py +3 -7
- empathy_llm_toolkit/context/__init__.py +22 -0
- empathy_llm_toolkit/context/compaction.py +455 -0
- empathy_llm_toolkit/context/manager.py +434 -0
- empathy_llm_toolkit/hooks/__init__.py +24 -0
- empathy_llm_toolkit/hooks/config.py +306 -0
- empathy_llm_toolkit/hooks/executor.py +289 -0
- empathy_llm_toolkit/hooks/registry.py +302 -0
- empathy_llm_toolkit/hooks/scripts/__init__.py +39 -0
- empathy_llm_toolkit/hooks/scripts/evaluate_session.py +201 -0
- empathy_llm_toolkit/hooks/scripts/first_time_init.py +285 -0
- empathy_llm_toolkit/hooks/scripts/pre_compact.py +207 -0
- empathy_llm_toolkit/hooks/scripts/session_end.py +183 -0
- empathy_llm_toolkit/hooks/scripts/session_start.py +163 -0
- empathy_llm_toolkit/hooks/scripts/suggest_compact.py +225 -0
- empathy_llm_toolkit/learning/__init__.py +30 -0
- empathy_llm_toolkit/learning/evaluator.py +438 -0
- empathy_llm_toolkit/learning/extractor.py +514 -0
- empathy_llm_toolkit/learning/storage.py +560 -0
- empathy_llm_toolkit/providers.py +4 -11
- empathy_llm_toolkit/security/__init__.py +17 -17
- empathy_llm_toolkit/utils/tokens.py +2 -5
- empathy_os/__init__.py +202 -70
- empathy_os/cache_monitor.py +5 -3
- empathy_os/cli/__init__.py +11 -55
- empathy_os/cli/__main__.py +29 -15
- empathy_os/cli/commands/inspection.py +21 -12
- empathy_os/cli/commands/memory.py +4 -12
- empathy_os/cli/commands/profiling.py +198 -0
- empathy_os/cli/commands/utilities.py +27 -7
- empathy_os/cli.py +28 -57
- empathy_os/cli_unified.py +525 -1164
- empathy_os/cost_tracker.py +9 -3
- empathy_os/dashboard/server.py +200 -2
- empathy_os/hot_reload/__init__.py +7 -7
- empathy_os/hot_reload/config.py +6 -7
- empathy_os/hot_reload/integration.py +35 -35
- empathy_os/hot_reload/reloader.py +57 -57
- empathy_os/hot_reload/watcher.py +28 -28
- empathy_os/hot_reload/websocket.py +2 -2
- empathy_os/memory/__init__.py +11 -4
- empathy_os/memory/claude_memory.py +1 -1
- empathy_os/memory/cross_session.py +8 -12
- empathy_os/memory/edges.py +6 -6
- empathy_os/memory/file_session.py +770 -0
- empathy_os/memory/graph.py +30 -30
- empathy_os/memory/nodes.py +6 -6
- empathy_os/memory/short_term.py +15 -9
- empathy_os/memory/unified.py +606 -140
- empathy_os/meta_workflows/agent_creator.py +3 -9
- empathy_os/meta_workflows/cli_meta_workflows.py +113 -53
- empathy_os/meta_workflows/form_engine.py +6 -18
- empathy_os/meta_workflows/intent_detector.py +64 -24
- empathy_os/meta_workflows/models.py +3 -1
- empathy_os/meta_workflows/pattern_learner.py +13 -31
- empathy_os/meta_workflows/plan_generator.py +55 -47
- empathy_os/meta_workflows/session_context.py +2 -3
- empathy_os/meta_workflows/workflow.py +20 -51
- empathy_os/models/cli.py +2 -2
- empathy_os/models/tasks.py +1 -2
- empathy_os/models/telemetry.py +4 -1
- empathy_os/models/token_estimator.py +3 -1
- empathy_os/monitoring/alerts.py +938 -9
- empathy_os/monitoring/alerts_cli.py +346 -183
- empathy_os/orchestration/execution_strategies.py +12 -29
- empathy_os/orchestration/pattern_learner.py +20 -26
- empathy_os/orchestration/real_tools.py +6 -15
- empathy_os/platform_utils.py +2 -1
- empathy_os/plugins/__init__.py +2 -2
- empathy_os/plugins/base.py +64 -64
- empathy_os/plugins/registry.py +32 -32
- empathy_os/project_index/index.py +49 -15
- empathy_os/project_index/models.py +1 -2
- empathy_os/project_index/reports.py +1 -1
- empathy_os/project_index/scanner.py +1 -0
- empathy_os/redis_memory.py +10 -7
- empathy_os/resilience/__init__.py +1 -1
- empathy_os/resilience/health.py +10 -10
- empathy_os/routing/__init__.py +7 -7
- empathy_os/routing/chain_executor.py +37 -37
- empathy_os/routing/classifier.py +36 -36
- empathy_os/routing/smart_router.py +40 -40
- empathy_os/routing/{wizard_registry.py → workflow_registry.py} +47 -47
- empathy_os/scaffolding/__init__.py +8 -8
- empathy_os/scaffolding/__main__.py +1 -1
- empathy_os/scaffolding/cli.py +28 -28
- empathy_os/socratic/__init__.py +3 -19
- empathy_os/socratic/ab_testing.py +25 -36
- empathy_os/socratic/blueprint.py +38 -38
- empathy_os/socratic/cli.py +34 -20
- empathy_os/socratic/collaboration.py +30 -28
- empathy_os/socratic/domain_templates.py +9 -1
- empathy_os/socratic/embeddings.py +17 -13
- empathy_os/socratic/engine.py +135 -70
- empathy_os/socratic/explainer.py +70 -60
- empathy_os/socratic/feedback.py +24 -19
- empathy_os/socratic/forms.py +15 -10
- empathy_os/socratic/generator.py +51 -35
- empathy_os/socratic/llm_analyzer.py +25 -23
- empathy_os/socratic/mcp_server.py +99 -159
- empathy_os/socratic/session.py +19 -13
- empathy_os/socratic/storage.py +98 -67
- empathy_os/socratic/success.py +38 -27
- empathy_os/socratic/visual_editor.py +51 -39
- empathy_os/socratic/web_ui.py +99 -66
- empathy_os/telemetry/cli.py +3 -1
- empathy_os/telemetry/usage_tracker.py +1 -3
- empathy_os/test_generator/__init__.py +3 -3
- empathy_os/test_generator/cli.py +28 -28
- empathy_os/test_generator/generator.py +64 -66
- empathy_os/test_generator/risk_analyzer.py +11 -11
- empathy_os/vscode_bridge.py +173 -0
- empathy_os/workflows/__init__.py +212 -120
- empathy_os/workflows/batch_processing.py +8 -24
- empathy_os/workflows/bug_predict.py +1 -1
- empathy_os/workflows/code_review.py +20 -5
- empathy_os/workflows/code_review_pipeline.py +13 -8
- empathy_os/workflows/keyboard_shortcuts/workflow.py +6 -2
- empathy_os/workflows/manage_documentation.py +1 -0
- empathy_os/workflows/orchestrated_health_check.py +6 -11
- empathy_os/workflows/orchestrated_release_prep.py +3 -3
- empathy_os/workflows/pr_review.py +18 -10
- empathy_os/workflows/progressive/__init__.py +2 -12
- empathy_os/workflows/progressive/cli.py +14 -37
- empathy_os/workflows/progressive/core.py +12 -12
- empathy_os/workflows/progressive/orchestrator.py +166 -144
- empathy_os/workflows/progressive/reports.py +22 -31
- empathy_os/workflows/progressive/telemetry.py +8 -14
- empathy_os/workflows/progressive/test_gen.py +29 -48
- empathy_os/workflows/progressive/workflow.py +31 -70
- empathy_os/workflows/release_prep.py +21 -6
- empathy_os/workflows/release_prep_crew.py +1 -0
- empathy_os/workflows/secure_release.py +13 -6
- empathy_os/workflows/security_audit.py +8 -3
- empathy_os/workflows/test_coverage_boost_crew.py +3 -2
- empathy_os/workflows/test_maintenance_crew.py +1 -0
- empathy_os/workflows/test_runner.py +16 -12
- empathy_software_plugin/SOFTWARE_PLUGIN_README.md +25 -703
- empathy_software_plugin/cli.py +0 -122
- coach_wizards/__init__.py +0 -45
- coach_wizards/accessibility_wizard.py +0 -91
- coach_wizards/api_wizard.py +0 -91
- coach_wizards/base_wizard.py +0 -209
- coach_wizards/cicd_wizard.py +0 -91
- coach_wizards/code_reviewer_README.md +0 -60
- coach_wizards/code_reviewer_wizard.py +0 -180
- coach_wizards/compliance_wizard.py +0 -91
- coach_wizards/database_wizard.py +0 -91
- coach_wizards/debugging_wizard.py +0 -91
- coach_wizards/documentation_wizard.py +0 -91
- coach_wizards/generate_wizards.py +0 -347
- coach_wizards/localization_wizard.py +0 -173
- coach_wizards/migration_wizard.py +0 -91
- coach_wizards/monitoring_wizard.py +0 -91
- coach_wizards/observability_wizard.py +0 -91
- coach_wizards/performance_wizard.py +0 -91
- coach_wizards/prompt_engineering_wizard.py +0 -661
- coach_wizards/refactoring_wizard.py +0 -91
- coach_wizards/scaling_wizard.py +0 -90
- coach_wizards/security_wizard.py +0 -92
- coach_wizards/testing_wizard.py +0 -91
- empathy_framework-4.6.6.dist-info/RECORD +0 -410
- empathy_llm_toolkit/wizards/__init__.py +0 -43
- empathy_llm_toolkit/wizards/base_wizard.py +0 -364
- empathy_llm_toolkit/wizards/customer_support_wizard.py +0 -190
- empathy_llm_toolkit/wizards/healthcare_wizard.py +0 -378
- empathy_llm_toolkit/wizards/patient_assessment_README.md +0 -64
- empathy_llm_toolkit/wizards/patient_assessment_wizard.py +0 -193
- empathy_llm_toolkit/wizards/technology_wizard.py +0 -209
- empathy_os/wizard_factory_cli.py +0 -170
- empathy_software_plugin/wizards/__init__.py +0 -42
- empathy_software_plugin/wizards/advanced_debugging_wizard.py +0 -395
- empathy_software_plugin/wizards/agent_orchestration_wizard.py +0 -511
- empathy_software_plugin/wizards/ai_collaboration_wizard.py +0 -503
- empathy_software_plugin/wizards/ai_context_wizard.py +0 -441
- empathy_software_plugin/wizards/ai_documentation_wizard.py +0 -503
- empathy_software_plugin/wizards/base_wizard.py +0 -288
- empathy_software_plugin/wizards/book_chapter_wizard.py +0 -519
- empathy_software_plugin/wizards/code_review_wizard.py +0 -604
- empathy_software_plugin/wizards/debugging/__init__.py +0 -50
- empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +0 -414
- empathy_software_plugin/wizards/debugging/config_loaders.py +0 -446
- empathy_software_plugin/wizards/debugging/fix_applier.py +0 -469
- empathy_software_plugin/wizards/debugging/language_patterns.py +0 -385
- empathy_software_plugin/wizards/debugging/linter_parsers.py +0 -470
- empathy_software_plugin/wizards/debugging/verification.py +0 -369
- empathy_software_plugin/wizards/enhanced_testing_wizard.py +0 -537
- empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +0 -816
- empathy_software_plugin/wizards/multi_model_wizard.py +0 -501
- empathy_software_plugin/wizards/pattern_extraction_wizard.py +0 -422
- empathy_software_plugin/wizards/pattern_retriever_wizard.py +0 -400
- empathy_software_plugin/wizards/performance/__init__.py +0 -9
- empathy_software_plugin/wizards/performance/bottleneck_detector.py +0 -221
- empathy_software_plugin/wizards/performance/profiler_parsers.py +0 -278
- empathy_software_plugin/wizards/performance/trajectory_analyzer.py +0 -429
- empathy_software_plugin/wizards/performance_profiling_wizard.py +0 -305
- empathy_software_plugin/wizards/prompt_engineering_wizard.py +0 -425
- empathy_software_plugin/wizards/rag_pattern_wizard.py +0 -461
- empathy_software_plugin/wizards/security/__init__.py +0 -32
- empathy_software_plugin/wizards/security/exploit_analyzer.py +0 -290
- empathy_software_plugin/wizards/security/owasp_patterns.py +0 -241
- empathy_software_plugin/wizards/security/vulnerability_scanner.py +0 -604
- empathy_software_plugin/wizards/security_analysis_wizard.py +0 -322
- empathy_software_plugin/wizards/security_learning_wizard.py +0 -740
- empathy_software_plugin/wizards/tech_debt_wizard.py +0 -726
- empathy_software_plugin/wizards/testing/__init__.py +0 -27
- empathy_software_plugin/wizards/testing/coverage_analyzer.py +0 -459
- empathy_software_plugin/wizards/testing/quality_analyzer.py +0 -525
- empathy_software_plugin/wizards/testing/test_suggester.py +0 -533
- empathy_software_plugin/wizards/testing_wizard.py +0 -274
- wizards/__init__.py +0 -82
- wizards/admission_assessment_wizard.py +0 -644
- wizards/care_plan.py +0 -321
- wizards/clinical_assessment.py +0 -769
- wizards/discharge_planning.py +0 -77
- wizards/discharge_summary_wizard.py +0 -468
- wizards/dosage_calculation.py +0 -497
- wizards/incident_report_wizard.py +0 -454
- wizards/medication_reconciliation.py +0 -85
- wizards/nursing_assessment.py +0 -171
- wizards/patient_education.py +0 -654
- wizards/quality_improvement.py +0 -705
- wizards/sbar_report.py +0 -324
- wizards/sbar_wizard.py +0 -608
- wizards/shift_handoff_wizard.py +0 -535
- wizards/soap_note_wizard.py +0 -679
- wizards/treatment_plan.py +0 -15
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/WHEEL +0 -0
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/entry_points.txt +0 -0
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/licenses/LICENSE +0 -0
wizards/quality_improvement.py
DELETED
|
@@ -1,705 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Quality Improvement Wizard - AI Nurse Florence
|
|
3
|
-
Following Wizard Pattern Implementation from coding instructions
|
|
4
|
-
Quality metrics tracking and improvement initiative workflows with AI-powered pattern analysis
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import logging
|
|
8
|
-
from datetime import datetime
|
|
9
|
-
from typing import Any
|
|
10
|
-
from uuid import uuid4
|
|
11
|
-
|
|
12
|
-
from fastapi import APIRouter, HTTPException
|
|
13
|
-
from pydantic import BaseModel
|
|
14
|
-
|
|
15
|
-
from ...services.openai_client import create_openai_service
|
|
16
|
-
from ...utils.config import get_educational_banner
|
|
17
|
-
|
|
18
|
-
logger = logging.getLogger(__name__)
|
|
19
|
-
|
|
20
|
-
router = APIRouter(
|
|
21
|
-
prefix="/wizard/quality-improvement",
|
|
22
|
-
tags=["wizards", "quality-improvement"],
|
|
23
|
-
responses={
|
|
24
|
-
404: {"description": "Wizard session not found"},
|
|
25
|
-
422: {"description": "Invalid step data"},
|
|
26
|
-
},
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
# Wizard session storage (Redis in production)
|
|
30
|
-
_wizard_sessions: dict[str, dict[str, Any]] = {}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class QualityImprovementStepData(BaseModel):
|
|
34
|
-
"""Data model for quality improvement step submission."""
|
|
35
|
-
|
|
36
|
-
step_data: dict[str, Any]
|
|
37
|
-
metrics: list[dict[str, Any]] | None = None
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@router.post("/start")
|
|
41
|
-
async def start_quality_improvement(
|
|
42
|
-
initiative_type: str = "general", department: str | None = None
|
|
43
|
-
):
|
|
44
|
-
"""Start quality improvement wizard following Wizard Pattern Implementation."""
|
|
45
|
-
wizard_id = str(uuid4())
|
|
46
|
-
|
|
47
|
-
session_data = {
|
|
48
|
-
"wizard_id": wizard_id,
|
|
49
|
-
"wizard_type": "quality_improvement",
|
|
50
|
-
"created_at": datetime.now().isoformat(),
|
|
51
|
-
"current_step": 1,
|
|
52
|
-
"total_steps": 5,
|
|
53
|
-
"completed_steps": [],
|
|
54
|
-
"data": {
|
|
55
|
-
"initiative_type": initiative_type,
|
|
56
|
-
"department": department,
|
|
57
|
-
"problem_identification": {},
|
|
58
|
-
"baseline_metrics": {},
|
|
59
|
-
"improvement_plan": {},
|
|
60
|
-
"implementation": {},
|
|
61
|
-
"evaluation": {},
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_wizard_sessions[wizard_id] = session_data
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
"banner": get_educational_banner(),
|
|
69
|
-
"wizard_id": wizard_id,
|
|
70
|
-
"wizard_type": "quality_improvement",
|
|
71
|
-
"current_step": 1,
|
|
72
|
-
"total_steps": 5,
|
|
73
|
-
"step_title": "Problem Identification",
|
|
74
|
-
"step_description": "Define the quality issue or opportunity for improvement",
|
|
75
|
-
"fields": [
|
|
76
|
-
{"name": "problem_statement", "type": "textarea", "required": True},
|
|
77
|
-
{
|
|
78
|
-
"name": "affected_population",
|
|
79
|
-
"type": "text",
|
|
80
|
-
"label": "Patient/staff population affected",
|
|
81
|
-
"required": True,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"name": "scope",
|
|
85
|
-
"type": "select",
|
|
86
|
-
"options": ["Unit-level", "Department-level", "Hospital-wide", "System-wide"],
|
|
87
|
-
"required": True,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"name": "current_impact",
|
|
91
|
-
"type": "textarea",
|
|
92
|
-
"label": "Current impact on care/outcomes",
|
|
93
|
-
"required": True,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"name": "root_causes",
|
|
97
|
-
"type": "textarea",
|
|
98
|
-
"label": "Suspected root causes",
|
|
99
|
-
"required": True,
|
|
100
|
-
},
|
|
101
|
-
{"name": "stakeholders", "type": "textarea", "required": True},
|
|
102
|
-
],
|
|
103
|
-
"educational_note": "Use SMART criteria when defining the problem. Consider using root cause analysis tools like fishbone diagrams.",
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
@router.get("/{wizard_id}/status")
|
|
108
|
-
async def get_quality_improvement_status(wizard_id: str):
|
|
109
|
-
"""Get quality improvement wizard status following Wizard Pattern Implementation."""
|
|
110
|
-
|
|
111
|
-
if wizard_id not in _wizard_sessions:
|
|
112
|
-
raise HTTPException(status_code=404, detail="Wizard session not found")
|
|
113
|
-
|
|
114
|
-
session = _wizard_sessions[wizard_id]
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
"banner": get_educational_banner(),
|
|
118
|
-
"wizard_id": wizard_id,
|
|
119
|
-
"wizard_type": session["wizard_type"],
|
|
120
|
-
"current_step": session["current_step"],
|
|
121
|
-
"total_steps": session["total_steps"],
|
|
122
|
-
"completed_steps": session["completed_steps"],
|
|
123
|
-
"progress": len(session["completed_steps"]) / session["total_steps"] * 100,
|
|
124
|
-
"status": (
|
|
125
|
-
"completed"
|
|
126
|
-
if len(session["completed_steps"]) == session["total_steps"]
|
|
127
|
-
else "in_progress"
|
|
128
|
-
),
|
|
129
|
-
"data": session["data"],
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
@router.post("/{wizard_id}/step/{step_number}")
|
|
134
|
-
async def submit_quality_improvement_step(
|
|
135
|
-
wizard_id: str, step_number: int, step_data: QualityImprovementStepData
|
|
136
|
-
):
|
|
137
|
-
"""Submit quality improvement step data following Wizard Pattern Implementation."""
|
|
138
|
-
|
|
139
|
-
if wizard_id not in _wizard_sessions:
|
|
140
|
-
raise HTTPException(status_code=404, detail="Wizard session not found")
|
|
141
|
-
|
|
142
|
-
session = _wizard_sessions[wizard_id]
|
|
143
|
-
|
|
144
|
-
if step_number != session["current_step"]:
|
|
145
|
-
raise HTTPException(
|
|
146
|
-
status_code=422,
|
|
147
|
-
detail=f"Invalid step. Expected step {session['current_step']}, got step {step_number}",
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
# Store step data based on step number
|
|
151
|
-
step_mapping = {
|
|
152
|
-
1: "problem_identification",
|
|
153
|
-
2: "baseline_metrics",
|
|
154
|
-
3: "improvement_plan",
|
|
155
|
-
4: "implementation",
|
|
156
|
-
5: "evaluation",
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if step_number in step_mapping:
|
|
160
|
-
session["data"][step_mapping[step_number]] = step_data.step_data
|
|
161
|
-
|
|
162
|
-
# Track metrics if provided
|
|
163
|
-
if step_data.metrics:
|
|
164
|
-
if "tracked_metrics" not in session["data"]:
|
|
165
|
-
session["data"]["tracked_metrics"] = []
|
|
166
|
-
session["data"]["tracked_metrics"].extend(step_data.metrics)
|
|
167
|
-
|
|
168
|
-
# Mark step as completed
|
|
169
|
-
if step_number not in session["completed_steps"]:
|
|
170
|
-
session["completed_steps"].append(step_number)
|
|
171
|
-
|
|
172
|
-
# Generate AI analysis based on step
|
|
173
|
-
ai_analysis = await _generate_qi_analysis(step_number, step_data.step_data, session["data"])
|
|
174
|
-
|
|
175
|
-
# Move to next step
|
|
176
|
-
if step_number < session["total_steps"]:
|
|
177
|
-
session["current_step"] = step_number + 1
|
|
178
|
-
next_step_info = _get_step_info(step_number + 1)
|
|
179
|
-
else:
|
|
180
|
-
next_step_info = None
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
"banner": get_educational_banner(),
|
|
184
|
-
"wizard_id": wizard_id,
|
|
185
|
-
"step_completed": step_number,
|
|
186
|
-
"current_step": session["current_step"],
|
|
187
|
-
"total_steps": session["total_steps"],
|
|
188
|
-
"progress": len(session["completed_steps"]) / session["total_steps"] * 100,
|
|
189
|
-
"status": (
|
|
190
|
-
"completed"
|
|
191
|
-
if len(session["completed_steps"]) == session["total_steps"]
|
|
192
|
-
else "in_progress"
|
|
193
|
-
),
|
|
194
|
-
"ai_analysis": ai_analysis,
|
|
195
|
-
"next_step": next_step_info,
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
@router.get("/{wizard_id}/step/{step_number}")
|
|
200
|
-
async def get_quality_improvement_step(wizard_id: str, step_number: int):
|
|
201
|
-
"""Get quality improvement step information."""
|
|
202
|
-
|
|
203
|
-
if wizard_id not in _wizard_sessions:
|
|
204
|
-
raise HTTPException(status_code=404, detail="Wizard session not found")
|
|
205
|
-
|
|
206
|
-
session = _wizard_sessions[wizard_id]
|
|
207
|
-
|
|
208
|
-
if step_number < 1 or step_number > session["total_steps"]:
|
|
209
|
-
raise HTTPException(status_code=422, detail="Invalid step number")
|
|
210
|
-
|
|
211
|
-
step_info = _get_step_info(step_number)
|
|
212
|
-
|
|
213
|
-
# Get previously entered data if exists
|
|
214
|
-
step_mapping = {
|
|
215
|
-
1: "problem_identification",
|
|
216
|
-
2: "baseline_metrics",
|
|
217
|
-
3: "improvement_plan",
|
|
218
|
-
4: "implementation",
|
|
219
|
-
5: "evaluation",
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
existing_data = session["data"].get(step_mapping.get(step_number, ""), {})
|
|
223
|
-
|
|
224
|
-
return {
|
|
225
|
-
"banner": get_educational_banner(),
|
|
226
|
-
"wizard_id": wizard_id,
|
|
227
|
-
"step_number": step_number,
|
|
228
|
-
"existing_data": existing_data,
|
|
229
|
-
**step_info,
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
@router.get("/{wizard_id}/metrics")
|
|
234
|
-
async def get_quality_metrics(wizard_id: str):
|
|
235
|
-
"""Get tracked quality metrics for the initiative."""
|
|
236
|
-
|
|
237
|
-
if wizard_id not in _wizard_sessions:
|
|
238
|
-
raise HTTPException(status_code=404, detail="Wizard session not found")
|
|
239
|
-
|
|
240
|
-
session = _wizard_sessions[wizard_id]
|
|
241
|
-
metrics = session["data"].get("tracked_metrics", [])
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
"banner": get_educational_banner(),
|
|
245
|
-
"wizard_id": wizard_id,
|
|
246
|
-
"metrics": metrics,
|
|
247
|
-
"baseline_data": session["data"].get("baseline_metrics", {}),
|
|
248
|
-
"evaluation_data": session["data"].get("evaluation", {}),
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
@router.delete("/{wizard_id}")
|
|
253
|
-
async def cancel_quality_improvement(wizard_id: str):
|
|
254
|
-
"""Cancel and delete quality improvement wizard session."""
|
|
255
|
-
|
|
256
|
-
if wizard_id not in _wizard_sessions:
|
|
257
|
-
raise HTTPException(status_code=404, detail="Wizard session not found")
|
|
258
|
-
|
|
259
|
-
del _wizard_sessions[wizard_id]
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
"banner": get_educational_banner(),
|
|
263
|
-
"message": "Quality improvement wizard session cancelled",
|
|
264
|
-
"wizard_id": wizard_id,
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
def _get_step_info(step_number: int) -> dict[str, Any]:
|
|
269
|
-
"""Get step configuration information."""
|
|
270
|
-
|
|
271
|
-
steps = {
|
|
272
|
-
1: {
|
|
273
|
-
"step_title": "Problem Identification",
|
|
274
|
-
"step_description": "Define the quality issue or opportunity for improvement",
|
|
275
|
-
"fields": [
|
|
276
|
-
{"name": "problem_statement", "type": "textarea", "required": True},
|
|
277
|
-
{
|
|
278
|
-
"name": "affected_population",
|
|
279
|
-
"type": "text",
|
|
280
|
-
"label": "Patient/staff population affected",
|
|
281
|
-
"required": True,
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"name": "scope",
|
|
285
|
-
"type": "select",
|
|
286
|
-
"options": ["Unit-level", "Department-level", "Hospital-wide", "System-wide"],
|
|
287
|
-
"required": True,
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
"name": "current_impact",
|
|
291
|
-
"type": "textarea",
|
|
292
|
-
"label": "Current impact on care/outcomes",
|
|
293
|
-
"required": True,
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
"name": "root_causes",
|
|
297
|
-
"type": "textarea",
|
|
298
|
-
"label": "Suspected root causes",
|
|
299
|
-
"required": True,
|
|
300
|
-
},
|
|
301
|
-
{"name": "stakeholders", "type": "textarea", "required": True},
|
|
302
|
-
],
|
|
303
|
-
"educational_note": "Use SMART criteria when defining the problem. Consider using root cause analysis tools like fishbone diagrams.",
|
|
304
|
-
},
|
|
305
|
-
2: {
|
|
306
|
-
"step_title": "Baseline Metrics",
|
|
307
|
-
"step_description": "Establish current performance and measurement criteria",
|
|
308
|
-
"fields": [
|
|
309
|
-
{"name": "primary_metric", "type": "text", "required": True},
|
|
310
|
-
{
|
|
311
|
-
"name": "primary_metric_value",
|
|
312
|
-
"type": "number",
|
|
313
|
-
"label": "Current value",
|
|
314
|
-
"required": True,
|
|
315
|
-
},
|
|
316
|
-
{"name": "secondary_metrics", "type": "textarea", "required": False},
|
|
317
|
-
{
|
|
318
|
-
"name": "data_source",
|
|
319
|
-
"type": "text",
|
|
320
|
-
"label": "How metrics are collected",
|
|
321
|
-
"required": True,
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
"name": "measurement_frequency",
|
|
325
|
-
"type": "select",
|
|
326
|
-
"options": ["Daily", "Weekly", "Monthly", "Quarterly"],
|
|
327
|
-
"required": True,
|
|
328
|
-
},
|
|
329
|
-
{"name": "target_value", "type": "number", "required": True},
|
|
330
|
-
{
|
|
331
|
-
"name": "target_timeline",
|
|
332
|
-
"type": "text",
|
|
333
|
-
"label": "Timeline to reach target",
|
|
334
|
-
"required": True,
|
|
335
|
-
},
|
|
336
|
-
],
|
|
337
|
-
"educational_note": "Ensure metrics are measurable, relevant, and align with organizational quality goals.",
|
|
338
|
-
},
|
|
339
|
-
3: {
|
|
340
|
-
"step_title": "Improvement Plan",
|
|
341
|
-
"step_description": "Develop PDSA (Plan-Do-Study-Act) improvement strategy",
|
|
342
|
-
"fields": [
|
|
343
|
-
{
|
|
344
|
-
"name": "aim_statement",
|
|
345
|
-
"type": "textarea",
|
|
346
|
-
"label": "SMART aim statement",
|
|
347
|
-
"required": True,
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
"name": "interventions",
|
|
351
|
-
"type": "textarea",
|
|
352
|
-
"label": "Planned interventions/changes",
|
|
353
|
-
"required": True,
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
"name": "evidence_base",
|
|
357
|
-
"type": "textarea",
|
|
358
|
-
"label": "Evidence supporting interventions",
|
|
359
|
-
"required": True,
|
|
360
|
-
},
|
|
361
|
-
{"name": "resources_needed", "type": "textarea", "required": True},
|
|
362
|
-
{
|
|
363
|
-
"name": "team_members",
|
|
364
|
-
"type": "textarea",
|
|
365
|
-
"label": "QI team members and roles",
|
|
366
|
-
"required": True,
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
"name": "timeline",
|
|
370
|
-
"type": "textarea",
|
|
371
|
-
"label": "Implementation timeline",
|
|
372
|
-
"required": True,
|
|
373
|
-
},
|
|
374
|
-
{"name": "barriers_anticipated", "type": "textarea", "required": True},
|
|
375
|
-
{"name": "mitigation_strategies", "type": "textarea", "required": True},
|
|
376
|
-
],
|
|
377
|
-
"educational_note": "Use evidence-based practices. Plan for small tests of change (PDSA cycles) before full implementation.",
|
|
378
|
-
},
|
|
379
|
-
4: {
|
|
380
|
-
"step_title": "Implementation",
|
|
381
|
-
"step_description": "Document implementation progress and adjustments",
|
|
382
|
-
"fields": [
|
|
383
|
-
{"name": "start_date", "type": "date", "required": True},
|
|
384
|
-
{"name": "interventions_completed", "type": "textarea", "required": True},
|
|
385
|
-
{"name": "staff_training_completed", "type": "boolean", "required": True},
|
|
386
|
-
{"name": "process_changes_made", "type": "textarea", "required": True},
|
|
387
|
-
{"name": "challenges_encountered", "type": "textarea", "required": True},
|
|
388
|
-
{
|
|
389
|
-
"name": "adjustments_made",
|
|
390
|
-
"type": "textarea",
|
|
391
|
-
"label": "PDSA adjustments",
|
|
392
|
-
"required": True,
|
|
393
|
-
},
|
|
394
|
-
{"name": "stakeholder_feedback", "type": "textarea", "required": False},
|
|
395
|
-
{"name": "current_adoption_rate", "type": "number", "unit": "%", "required": True},
|
|
396
|
-
],
|
|
397
|
-
"educational_note": "Document all PDSA cycles. Be prepared to adapt the plan based on real-world feedback.",
|
|
398
|
-
},
|
|
399
|
-
5: {
|
|
400
|
-
"step_title": "Evaluation & Sustainability",
|
|
401
|
-
"step_description": "Assess outcomes and plan for sustained improvement",
|
|
402
|
-
"fields": [
|
|
403
|
-
{"name": "end_date", "type": "date", "required": True},
|
|
404
|
-
{
|
|
405
|
-
"name": "final_metric_value",
|
|
406
|
-
"type": "number",
|
|
407
|
-
"label": "Final primary metric value",
|
|
408
|
-
"required": True,
|
|
409
|
-
},
|
|
410
|
-
{"name": "target_achieved", "type": "boolean", "required": True},
|
|
411
|
-
{"name": "outcome_summary", "type": "textarea", "required": True},
|
|
412
|
-
{"name": "lessons_learned", "type": "textarea", "required": True},
|
|
413
|
-
{
|
|
414
|
-
"name": "sustainability_plan",
|
|
415
|
-
"type": "textarea",
|
|
416
|
-
"label": "How improvements will be sustained",
|
|
417
|
-
"required": True,
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
"name": "monitoring_frequency",
|
|
421
|
-
"type": "select",
|
|
422
|
-
"label": "Ongoing monitoring plan",
|
|
423
|
-
"options": ["Daily", "Weekly", "Monthly", "Quarterly"],
|
|
424
|
-
"required": True,
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
"name": "spread_potential",
|
|
428
|
-
"type": "textarea",
|
|
429
|
-
"label": "Potential to spread to other units",
|
|
430
|
-
"required": False,
|
|
431
|
-
},
|
|
432
|
-
{"name": "next_steps", "type": "textarea", "required": True},
|
|
433
|
-
],
|
|
434
|
-
"educational_note": "Celebrate successes! Share results with stakeholders. Plan for ongoing monitoring to prevent backsliding.",
|
|
435
|
-
},
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return steps.get(step_number, {})
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
@router.get("/templates")
|
|
442
|
-
async def get_quality_improvement_templates():
|
|
443
|
-
"""Get common quality improvement initiative templates."""
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
"banner": get_educational_banner(),
|
|
447
|
-
"templates": [
|
|
448
|
-
{
|
|
449
|
-
"name": "Fall Prevention",
|
|
450
|
-
"description": "Reduce patient falls and fall-related injuries",
|
|
451
|
-
"common_metrics": [
|
|
452
|
-
"Falls per 1000 patient days",
|
|
453
|
-
"Fall-related injury rate",
|
|
454
|
-
"Post-fall huddle completion rate",
|
|
455
|
-
],
|
|
456
|
-
"evidence_based_interventions": [
|
|
457
|
-
"Hourly rounding",
|
|
458
|
-
"Fall risk assessment on admission",
|
|
459
|
-
"Yellow socks/wristbands for high-risk patients",
|
|
460
|
-
"Bed alarms for appropriate patients",
|
|
461
|
-
"Environmental safety checks",
|
|
462
|
-
],
|
|
463
|
-
},
|
|
464
|
-
{
|
|
465
|
-
"name": "Pressure Injury Prevention",
|
|
466
|
-
"description": "Prevent hospital-acquired pressure injuries",
|
|
467
|
-
"common_metrics": [
|
|
468
|
-
"Hospital-acquired pressure injury rate",
|
|
469
|
-
"Skin assessment completion rate",
|
|
470
|
-
"Turn compliance rate",
|
|
471
|
-
],
|
|
472
|
-
"evidence_based_interventions": [
|
|
473
|
-
"Braden scale assessment on admission",
|
|
474
|
-
"Turn schedule implementation",
|
|
475
|
-
"Specialty mattress utilization",
|
|
476
|
-
"Nutritional support",
|
|
477
|
-
"Heel offloading protocols",
|
|
478
|
-
],
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
"name": "CAUTI Prevention",
|
|
482
|
-
"description": "Reduce catheter-associated urinary tract infections",
|
|
483
|
-
"common_metrics": [
|
|
484
|
-
"CAUTI rate per 1000 catheter days",
|
|
485
|
-
"Catheter utilization ratio",
|
|
486
|
-
"Appropriate indication documentation",
|
|
487
|
-
],
|
|
488
|
-
"evidence_based_interventions": [
|
|
489
|
-
"Daily catheter necessity assessment",
|
|
490
|
-
"Aseptic insertion technique",
|
|
491
|
-
"Proper catheter maintenance",
|
|
492
|
-
"Early removal protocols",
|
|
493
|
-
"Nurse-driven removal protocols",
|
|
494
|
-
],
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
"name": "Medication Safety",
|
|
498
|
-
"description": "Reduce medication errors and adverse drug events",
|
|
499
|
-
"common_metrics": [
|
|
500
|
-
"Medication error rate",
|
|
501
|
-
"Adverse drug event rate",
|
|
502
|
-
"High-alert medication compliance",
|
|
503
|
-
],
|
|
504
|
-
"evidence_based_interventions": [
|
|
505
|
-
"Double-check protocols for high-alert meds",
|
|
506
|
-
"Barcode scanning compliance",
|
|
507
|
-
"Medication reconciliation",
|
|
508
|
-
"Smart pump utilization",
|
|
509
|
-
"Pharmacist involvement in rounds",
|
|
510
|
-
],
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
"name": "Hand Hygiene Compliance",
|
|
514
|
-
"description": "Improve hand hygiene compliance rates",
|
|
515
|
-
"common_metrics": [
|
|
516
|
-
"Hand hygiene compliance rate",
|
|
517
|
-
"Healthcare-associated infection rates",
|
|
518
|
-
"Audit completion rate",
|
|
519
|
-
],
|
|
520
|
-
"evidence_based_interventions": [
|
|
521
|
-
"Alcohol-based hand sanitizer placement",
|
|
522
|
-
"Visual reminders at point of care",
|
|
523
|
-
"Direct observation audits",
|
|
524
|
-
"Peer accountability",
|
|
525
|
-
"Leadership rounding with feedback",
|
|
526
|
-
],
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
"name": "Patient Satisfaction",
|
|
530
|
-
"description": "Improve patient experience and satisfaction scores",
|
|
531
|
-
"common_metrics": [
|
|
532
|
-
"HCAHPS scores",
|
|
533
|
-
"Response rate to call lights",
|
|
534
|
-
"Hourly rounding completion",
|
|
535
|
-
],
|
|
536
|
-
"evidence_based_interventions": [
|
|
537
|
-
"Bedside shift report",
|
|
538
|
-
"Hourly rounding with 4 Ps (Pain, Potty, Position, Possessions)",
|
|
539
|
-
"Leader rounding",
|
|
540
|
-
"Discharge phone calls",
|
|
541
|
-
"White board communication",
|
|
542
|
-
],
|
|
543
|
-
},
|
|
544
|
-
],
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
async def _generate_qi_analysis(
|
|
549
|
-
step_number: int, step_data: dict[str, Any], all_data: dict[str, Any]
|
|
550
|
-
) -> dict[str, Any]:
|
|
551
|
-
"""
|
|
552
|
-
Generate AI-powered quality improvement analysis for each step.
|
|
553
|
-
Provides pattern analysis, root cause identification, evidence-based interventions, and outcome predictions.
|
|
554
|
-
"""
|
|
555
|
-
|
|
556
|
-
step_names = {
|
|
557
|
-
1: "Problem Identification",
|
|
558
|
-
2: "Baseline Metrics",
|
|
559
|
-
3: "Improvement Plan",
|
|
560
|
-
4: "Implementation",
|
|
561
|
-
5: "Evaluation & Sustainability",
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
step_name = step_names.get(step_number, "Unknown Step")
|
|
565
|
-
|
|
566
|
-
try:
|
|
567
|
-
service = create_openai_service()
|
|
568
|
-
|
|
569
|
-
if not service:
|
|
570
|
-
return _fallback_qi_analysis(step_name)
|
|
571
|
-
|
|
572
|
-
# Create analysis prompt based on step
|
|
573
|
-
if step_number == 1:
|
|
574
|
-
# Root cause analysis and pattern identification
|
|
575
|
-
prompt = f"""Analyze this quality improvement problem and provide professional nursing insights:
|
|
576
|
-
|
|
577
|
-
Problem Statement: {step_data.get('problem_statement', 'N/A')}
|
|
578
|
-
Affected Population: {step_data.get('affected_population', 'N/A')}
|
|
579
|
-
Scope: {step_data.get('scope', 'N/A')}
|
|
580
|
-
Current Impact: {step_data.get('current_impact', 'N/A')}
|
|
581
|
-
Suspected Root Causes: {step_data.get('root_causes', 'N/A')}
|
|
582
|
-
Stakeholders: {step_data.get('stakeholders', 'N/A')}
|
|
583
|
-
|
|
584
|
-
Provide:
|
|
585
|
-
1. Root cause analysis using systems thinking
|
|
586
|
-
2. Contributing factors across people, process, environment, and equipment
|
|
587
|
-
3. Similar quality issues in nursing literature
|
|
588
|
-
4. Priority areas for data collection and baseline measurement
|
|
589
|
-
5. Stakeholder engagement strategies"""
|
|
590
|
-
|
|
591
|
-
elif step_number == 2:
|
|
592
|
-
# Metrics analysis and benchmarking
|
|
593
|
-
prompt = f"""Analyze these baseline quality metrics and provide evidence-based insights:
|
|
594
|
-
|
|
595
|
-
Primary Metric: {step_data.get('primary_metric', 'N/A')}
|
|
596
|
-
Current Value: {step_data.get('primary_metric_value', 'N/A')}
|
|
597
|
-
Target Value: {step_data.get('target_value', 'N/A')}
|
|
598
|
-
Secondary Metrics: {step_data.get('secondary_metrics', 'N/A')}
|
|
599
|
-
Data Source: {step_data.get('data_source', 'N/A')}
|
|
600
|
-
Measurement Frequency: {step_data.get('measurement_frequency', 'N/A')}
|
|
601
|
-
Target Timeline: {step_data.get('target_timeline', 'N/A')}
|
|
602
|
-
|
|
603
|
-
Provide:
|
|
604
|
-
1. Assessment of current performance vs. national benchmarks
|
|
605
|
-
2. Statistical significance of improvement needed
|
|
606
|
-
3. Run chart and control chart recommendations
|
|
607
|
-
4. Balance measures to monitor for unintended consequences
|
|
608
|
-
5. Data collection and validation strategies"""
|
|
609
|
-
|
|
610
|
-
elif step_number == 3:
|
|
611
|
-
# Evidence-based intervention recommendations
|
|
612
|
-
prompt = f"""Analyze this quality improvement plan and provide evidence-based recommendations:
|
|
613
|
-
|
|
614
|
-
Aim Statement: {step_data.get('aim_statement', 'N/A')}
|
|
615
|
-
Planned Interventions: {step_data.get('interventions', 'N/A')}
|
|
616
|
-
Evidence Base: {step_data.get('evidence_base', 'N/A')}
|
|
617
|
-
Resources Needed: {step_data.get('resources_needed', 'N/A')}
|
|
618
|
-
Team Members: {step_data.get('team_members', 'N/A')}
|
|
619
|
-
Timeline: {step_data.get('timeline', 'N/A')}
|
|
620
|
-
Anticipated Barriers: {step_data.get('barriers_anticipated', 'N/A')}
|
|
621
|
-
|
|
622
|
-
Provide:
|
|
623
|
-
1. Strength of evidence for proposed interventions (cite nursing research)
|
|
624
|
-
2. Additional evidence-based interventions to consider
|
|
625
|
-
3. PDSA cycle recommendations for testing changes
|
|
626
|
-
4. Change management strategies for adoption
|
|
627
|
-
5. Risk mitigation for identified barriers"""
|
|
628
|
-
|
|
629
|
-
elif step_number == 4:
|
|
630
|
-
# Implementation progress analysis
|
|
631
|
-
prompt = f"""Analyze quality improvement implementation progress:
|
|
632
|
-
|
|
633
|
-
Start Date: {step_data.get('start_date', 'N/A')}
|
|
634
|
-
Interventions Completed: {step_data.get('interventions_completed', 'N/A')}
|
|
635
|
-
Process Changes: {step_data.get('process_changes_made', 'N/A')}
|
|
636
|
-
Challenges Encountered: {step_data.get('challenges_encountered', 'N/A')}
|
|
637
|
-
Adjustments Made: {step_data.get('adjustments_made', 'N/A')}
|
|
638
|
-
Current Adoption Rate: {step_data.get('current_adoption_rate', 'N/A')}%
|
|
639
|
-
|
|
640
|
-
Baseline Data: {all_data.get('baseline_metrics', {})}
|
|
641
|
-
|
|
642
|
-
Provide:
|
|
643
|
-
1. Assessment of implementation fidelity
|
|
644
|
-
2. Adoption rate analysis and strategies to improve
|
|
645
|
-
3. Recommended PDSA adjustments based on challenges
|
|
646
|
-
4. Early indicator analysis (are we on track?)
|
|
647
|
-
5. Staff engagement and sustainability recommendations"""
|
|
648
|
-
|
|
649
|
-
elif step_number == 5:
|
|
650
|
-
# Comprehensive outcome analysis
|
|
651
|
-
prompt = f"""Analyze quality improvement initiative outcomes and sustainability:
|
|
652
|
-
|
|
653
|
-
Initiative: {all_data.get('problem_identification', {}).get('problem_statement', 'N/A')}
|
|
654
|
-
Baseline Value: {all_data.get('baseline_metrics', {}).get('primary_metric_value', 'N/A')}
|
|
655
|
-
Final Value: {step_data.get('final_metric_value', 'N/A')}
|
|
656
|
-
Target Achieved: {step_data.get('target_achieved', 'N/A')}
|
|
657
|
-
Outcome Summary: {step_data.get('outcome_summary', 'N/A')}
|
|
658
|
-
Lessons Learned: {step_data.get('lessons_learned', 'N/A')}
|
|
659
|
-
Sustainability Plan: {step_data.get('sustainability_plan', 'N/A')}
|
|
660
|
-
Spread Potential: {step_data.get('spread_potential', 'N/A')}
|
|
661
|
-
|
|
662
|
-
Provide:
|
|
663
|
-
1. Statistical and clinical significance of results
|
|
664
|
-
2. Success factors and key lessons learned
|
|
665
|
-
3. Sustainability recommendations and monitoring plan
|
|
666
|
-
4. Spread strategy for other units/facilities
|
|
667
|
-
5. Publication/presentation opportunities (professional development)"""
|
|
668
|
-
|
|
669
|
-
else:
|
|
670
|
-
prompt = f"Analyze quality improvement data for {step_name}: {step_data}"
|
|
671
|
-
|
|
672
|
-
# Generate AI analysis
|
|
673
|
-
ai_response = await service.generate_response(
|
|
674
|
-
prompt=prompt, context="quality_improvement_analysis"
|
|
675
|
-
)
|
|
676
|
-
|
|
677
|
-
return {
|
|
678
|
-
"step_name": step_name,
|
|
679
|
-
"analysis_available": True,
|
|
680
|
-
"qi_insights": ai_response.get("response", "AI analysis temporarily unavailable"),
|
|
681
|
-
"evidence_level": "AI-generated recommendations based on nursing literature and best practices",
|
|
682
|
-
"disclaimer": "AI-generated quality improvement insights for professional use. Validate recommendations with organizational policies and evidence-based guidelines.",
|
|
683
|
-
"ai_model": ai_response.get("model", "gpt-4"),
|
|
684
|
-
"service_status": ai_response.get("service_status", "available"),
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
except Exception as e:
|
|
688
|
-
logger.error(f"QI AI analysis failed for step {step_number}: {e}")
|
|
689
|
-
return _fallback_qi_analysis(step_name)
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
def _fallback_qi_analysis(step_name: str) -> dict[str, Any]:
|
|
693
|
-
"""Fallback QI analysis when AI is unavailable."""
|
|
694
|
-
return {
|
|
695
|
-
"step_name": step_name,
|
|
696
|
-
"analysis_available": False,
|
|
697
|
-
"message": "AI quality improvement analysis temporarily unavailable",
|
|
698
|
-
"fallback_note": "Proceed with quality improvement using standard QI methodologies (PDSA, Lean, Six Sigma) and organizational QI resources",
|
|
699
|
-
"recommended_resources": [
|
|
700
|
-
"Institute for Healthcare Improvement (IHI) resources",
|
|
701
|
-
"Agency for Healthcare Research and Quality (AHRQ) toolkit",
|
|
702
|
-
"Organizational quality improvement department",
|
|
703
|
-
"Professional QI literature and evidence-based guidelines",
|
|
704
|
-
],
|
|
705
|
-
}
|