DocUA commited on
Commit
a4bb4ba
·
1 Parent(s): cc9377e

docs: Create implementation plan for simplified spiritual triage

Browse files

9 phases, 15 main tasks:
- Phase 1: Remove Lifestyle Mode (4 subtasks)
- Phase 2: Spiritual State Machine (3 subtasks)
- Phase 3: Spiritual Monitor (5 subtasks)
- Phase 4: Soft Triage Manager (6 subtasks)
- Phase 5: Main App Integration (7 subtasks)
- Phase 6: Referral Generation (3 subtasks)
- Phase 7: Language Support (4 subtasks)
- Phase 8: UI Simplification (3 subtasks)
- Phase 9: Final Testing (5 subtasks)

14 property-based tests mapped to requirements

.kiro/specs/simplified-spiritual-triage/tasks.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Implementation Plan
2
+
3
+ ## Phase 1: Remove Lifestyle Mode
4
+
5
+ - [ ] 1. Remove Lifestyle components from codebase
6
+ - [ ] 1.1 Remove MainLifestyleAssistant from lifestyle_app.py
7
+ - Delete lifestyle assistant initialization
8
+ - Remove lifestyle mode handling in process_message
9
+ - _Requirements: 1.1, 1.2_
10
+ - [ ] 1.2 Remove CombinedAssistant and related code
11
+ - Delete src/core/combined_assistant.py
12
+ - Remove combined mode from AssistantMode enum
13
+ - _Requirements: 1.1, 1.2_
14
+ - [ ] 1.3 Simplify AssistantMode enum
15
+ - Keep only: MEDICAL, SPIRITUAL (internal), NONE
16
+ - Remove: LIFESTYLE, COMBINED
17
+ - _Requirements: 1.1_
18
+ - [ ] 1.4 Update UI to remove mode selector
19
+ - Remove assistant mode radio buttons
20
+ - Single unified medical interface
21
+ - _Requirements: 1.3_
22
+
23
+ ## Phase 2: Implement Spiritual State Machine
24
+
25
+ - [ ] 2. Create SpiritualState and data models
26
+ - [ ] 2.1 Create src/core/spiritual_state.py with enums and dataclasses
27
+ - SpiritualState enum (GREEN, YELLOW, RED)
28
+ - TriageOutcome enum
29
+ - SpiritualAssessment dataclass
30
+ - TriageSession dataclass
31
+ - _Requirements: 5.1, 7.1_
32
+ - [ ]* 2.2 Write property test for state validity
33
+ - **Property 8: State Validity**
34
+ - **Validates: Requirements 5.1, 7.1**
35
+
36
+ - [ ] 3. Implement SessionStateManager
37
+ - [ ] 3.1 Create SessionStateManager class
38
+ - Track current spiritual state
39
+ - Track triage question count
40
+ - Implement state transitions
41
+ - _Requirements: 7.1, 7.2_
42
+ - [ ]* 3.2 Write property test for session reset
43
+ - **Property 14: Session Reset**
44
+ - **Validates: Requirements 7.4**
45
+
46
+ ## Phase 3: Implement Spiritual Monitor
47
+
48
+ - [ ] 4. Refactor SpiritualDistressAnalyzer to SpiritualMonitor
49
+ - [ ] 4.1 Simplify classification to GREEN/YELLOW/RED
50
+ - Rename and refactor existing analyzer
51
+ - Return SpiritualState instead of DistressClassification
52
+ - _Requirements: 2.1, 5.1_
53
+ - [ ]* 4.2 Write property test for monitor invocation
54
+ - **Property 1: Spiritual Monitor Always Invoked**
55
+ - **Validates: Requirements 2.1**
56
+ - [ ]* 4.3 Write property test for conservative classification
57
+ - **Property 9: Conservative Classification**
58
+ - **Validates: Requirements 5.2**
59
+ - [ ]* 4.4 Write property test for red flag keywords
60
+ - **Property 10: Red Flag Keywords**
61
+ - **Validates: Requirements 5.4**
62
+
63
+ - [ ] 5. Checkpoint - Ensure all tests pass
64
+ - Ensure all tests pass, ask the user if questions arise.
65
+
66
+ ## Phase 4: Implement Soft Triage Manager
67
+
68
+ - [ ] 6. Create SoftTriageManager
69
+ - [ ] 6.1 Implement triage question generation
70
+ - Generate empathetic clarifying questions
71
+ - Use LLM with appropriate prompt
72
+ - Match patient language
73
+ - _Requirements: 3.1, 3.2, 8.3_
74
+ - [ ] 6.2 Implement response evaluation
75
+ - Evaluate patient responses
76
+ - Determine TriageOutcome (RESOLVED_GREEN, ESCALATE_RED, CONTINUE)
77
+ - _Requirements: 3.3_
78
+ - [ ] 6.3 Implement question limit enforcement
79
+ - Track question count (max 3)
80
+ - Force decision after 3 exchanges
81
+ - _Requirements: 3.1, 3.6_
82
+ - [ ]* 6.4 Write property test for triage question limit
83
+ - **Property 5: Triage Question Limit**
84
+ - **Validates: Requirements 3.1, 7.2**
85
+ - [ ]* 6.5 Write property test for triage binary outcome
86
+ - **Property 6: Triage Binary Outcome**
87
+ - **Validates: Requirements 3.3**
88
+ - [ ]* 6.6 Write property test for triage timeout escalation
89
+ - **Property 7: Triage Timeout Escalation**
90
+ - **Validates: Requirements 3.6**
91
+
92
+ ## Phase 5: Integrate into Main App
93
+
94
+ - [ ] 7. Integrate Spiritual Monitor into message processing
95
+ - [ ] 7.1 Update process_message to use SpiritualMonitor
96
+ - Call monitor for every message
97
+ - Route based on SpiritualState
98
+ - _Requirements: 2.1, 2.2, 2.3, 2.4_
99
+ - [ ]* 7.2 Write property test for green state preservation
100
+ - **Property 2: Green State Preservation**
101
+ - **Validates: Requirements 2.2**
102
+ - [ ]* 7.3 Write property test for yellow triggers triage
103
+ - **Property 3: Yellow Triggers Triage**
104
+ - **Validates: Requirements 2.3**
105
+ - [ ]* 7.4 Write property test for red triggers referral
106
+ - **Property 4: Red Triggers Immediate Referral**
107
+ - **Validates: Requirements 2.4**
108
+
109
+ - [ ] 8. Implement state transitions in app
110
+ - [ ] 8.1 Handle GREEN → YELLOW transition
111
+ - Initiate SoftTriageManager
112
+ - Generate first triage question
113
+ - _Requirements: 2.3, 3.1_
114
+ - [ ] 8.2 Handle YELLOW → GREEN transition (resolved)
115
+ - Return to medical dialog
116
+ - Reset triage session
117
+ - _Requirements: 3.4_
118
+ - [ ] 8.3 Handle YELLOW → RED transition (escalated)
119
+ - Generate referral
120
+ - Provide crisis support
121
+ - _Requirements: 3.5, 6.1_
122
+
123
+ - [ ] 9. Checkpoint - Ensure all tests pass
124
+ - Ensure all tests pass, ask the user if questions arise.
125
+
126
+ ## Phase 6: Update Referral Generation
127
+
128
+ - [ ] 10. Ensure referral generation works with new flow
129
+ - [ ] 10.1 Update ReferralMessageGenerator for simplified flow
130
+ - Accept SpiritualAssessment instead of DistressClassification
131
+ - Include triage context if available
132
+ - _Requirements: 6.1, 6.2_
133
+ - [ ]* 10.2 Write property test for referral generation on red
134
+ - **Property 11: Referral Generation on Red**
135
+ - **Validates: Requirements 6.1**
136
+ - [ ]* 10.3 Write property test for referral content completeness
137
+ - **Property 12: Referral Content Completeness**
138
+ - **Validates: Requirements 6.2**
139
+
140
+ ## Phase 7: Language Support
141
+
142
+ - [ ] 11. Ensure language matching across all components
143
+ - [ ] 11.1 Verify SpiritualMonitor language handling
144
+ - Classification reasoning in patient language
145
+ - _Requirements: 8.1, 8.2_
146
+ - [ ] 11.2 Verify SoftTriageManager language handling
147
+ - Questions in patient language
148
+ - _Requirements: 8.3_
149
+ - [ ] 11.3 Verify ReferralMessageGenerator language handling
150
+ - Referrals in patient language
151
+ - _Requirements: 8.4_
152
+ - [ ]* 11.4 Write property test for language matching
153
+ - **Property 13: Language Matching**
154
+ - **Validates: Requirements 8.1, 8.2, 8.3, 8.4**
155
+
156
+ ## Phase 8: UI Simplification
157
+
158
+ - [ ] 12. Simplify Gradio interface
159
+ - [ ] 12.1 Remove mode selector from UI
160
+ - Single medical assistant interface
161
+ - No visible mode switching
162
+ - _Requirements: 1.3, 4.1_
163
+ - [ ] 12.2 Update status display
164
+ - Show spiritual state for debugging (optional)
165
+ - Clean user-facing interface
166
+ - _Requirements: 4.1_
167
+ - [ ] 12.3 Remove Edit Prompts for Lifestyle
168
+ - Keep only Medical and Spiritual prompts
169
+ - _Requirements: 1.1_
170
+
171
+ ## Phase 9: Final Testing and Cleanup
172
+
173
+ - [ ] 13. Final integration testing
174
+ - [ ] 13.1 Test full flow: GREEN → YELLOW → GREEN
175
+ - Patient shows mild distress, triage resolves positively
176
+ - _Requirements: 2.2, 2.3, 3.4_
177
+ - [ ] 13.2 Test full flow: GREEN → YELLOW → RED
178
+ - Patient shows mild distress, triage confirms serious issue
179
+ - _Requirements: 2.3, 3.5, 6.1_
180
+ - [ ] 13.3 Test full flow: GREEN → RED (immediate)
181
+ - Patient shows severe distress, immediate referral
182
+ - _Requirements: 2.4, 6.1_
183
+ - [ ] 13.4 Test language switching
184
+ - Ukrainian and English conversations
185
+ - _Requirements: 8.1, 8.2_
186
+
187
+ - [ ] 14. Cleanup and documentation
188
+ - [ ] 14.1 Remove unused Lifestyle code files
189
+ - Delete deprecated files
190
+ - Update imports
191
+ - _Requirements: 1.2_
192
+ - [ ] 14.2 Update README for simplified architecture
193
+ - Document new flow
194
+ - Update quick start guide
195
+ - _Requirements: 1.1_
196
+
197
+ - [ ] 15. Final Checkpoint - Ensure all tests pass
198
+ - Ensure all tests pass, ask the user if questions arise.