Skip to content

Refactor/rf005 incidnet tracking status - #70

Merged
DuongNManh merged 3 commits into
devfrom
refactor/RF005-incidnet-tracking-status
May 5, 2026
Merged

Refactor/rf005 incidnet tracking status#70
DuongNManh merged 3 commits into
devfrom
refactor/RF005-incidnet-tracking-status

Conversation

@DuongNManh

@DuongNManh DuongNManh commented May 5, 2026

Copy link
Copy Markdown
Contributor

Add new stream subscription listening on IncidentFalseAlarm and NoRescuerFound events to terminate the emergency tracking screen. Update Incident finished detail information with operatorNotes and CancellationReason

Summary by CodeRabbit

Ghi chú phát hành

  • Tính năng mới
    • Thêm xử lý sự kiện cảnh báo dương tính giả từ MissionHub với tin nhắn thông báo.
    • Thêm xử lý sự kiện chuyển giao bệnh nhân tới bệnh viện với dialog xác nhận.
    • Thêm hiển thị ghi chú điều phối viên và lý do hủy trong chi tiết sự cố.

DuongNManh added 3 commits May 6, 2026 02:19
…dels, update mission status and tracking screen to handle new events
…to refactor/RF005-incidnet-tracking-status
@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a3a3915-8212-4574-8ceb-4dbcb50cad9a

📥 Commits

Reviewing files that changed from the base of the PR and between d57e5b7 and 2b971ed.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • lib/core/services/mission_hub_service.dart
  • lib/features/emergency/models/detailed_incident_response.dart
  • lib/features/emergency/providers/mission_hub_provider.dart
  • lib/features/emergency/screens/members/emergency_tracking_screen.dart
  • lib/features/member/screens/member_incident_finished_detail_screen.dart

📝 Walkthrough

Walkthrough

PR thêm hai sự kiện MissionHub mới (IncidentFalseAlarmData, HospitalHandoverAcceptedData) với stream controllers và xử lý SignalR tương ứng. Mở rộng MissionStatus để lưu trữ trạng thái này, cập nhật giao diện để hiển thị và xử lý các sự kiện trên, cũng như thêm trường operatorNotes vào chi tiết sự cố.

Changes

Xử lý Sự kiện MissionHub: Báo Động Giả và Bàn Giao Bệnh Viện

Layer / File(s) Summary
Định nghĩa Dữ liệu Sự kiện
lib/core/services/mission_hub_service.dart
Thêm hai lớp dữ liệu: IncidentFalseAlarmData (với falseAlarmReason) và HospitalHandoverAcceptedData (với hospitalName, hospitalPhone, operatorNote), cả hai có logic fromJson xử lý khóa PascalCase/camelCase với fallback DateTime.
Stream Controllers & Getters
lib/core/services/mission_hub_service.dart
Thêm _incidentFalseAlarmController, _hospitalHandoverAcceptedController và các public stream getter tương ứng; cập nhật dispose() đóng chúng.
Đăng ký Xử lý SignalR
lib/core/services/mission_hub_service.dart
Đăng ký hai handler: IncidentFalseAlarmHospitalHandoverAccepted, mỗi handler chuyển đổi đối số Map thành dữ liệu model và phát ra stream.
Mô hình Dữ liệu Chi tiết
lib/features/emergency/models/detailed_incident_response.dart
Thêm trường operatorNotes: String? vào DetailedIncidentData; cập nhật constructor, fromJson, toJson để xử lý trường mới.
Quản lý Trạng thái Mission
lib/features/emergency/providers/mission_hub_provider.dart
Mở rộng MissionStatus với sáu trường mới: incidentFalseAlarm, incidentFalseAlarmReason, hospitalHandoverAccepted, hospitalName, hospitalPhone, hospitalOperatorNote; cập nhật constructor, copyWith; MissionStatusNotifier subscribe tới hai stream sự kiện mới và cập nhật state.
Xử lý UI — Màn hình Theo dõi
lib/features/emergency/screens/members/emergency_tracking_screen.dart
Thêm guard _isTerminating, hai handler stream trong _setupMissionHubListeners() (báo động giả → kết thúc về nhà; bàn giao bệnh viện → hiển thị dialog → kết thúc); thêm _terminateToHome() (ngắt MissionHub, reset provider, điều hướng) và _showHospitalHandoverAcceptedDialog() (hiển thị thông tin bệnh viện và note).
Hiển thị Chi tiết Sự cố Đã Xong
lib/features/member/screens/member_incident_finished_detail_screen.dart
Thêm hai dòng thông tin có điều kiện trong _buildIncidentInfoCard(): hiển thị operatorNotes (nếu non-null/non-empty) và cancellationReason (nếu non-null/non-empty).

Sequence Diagrams

sequenceDiagram
    participant SignalR as SignalR Hub
    participant MHS as MissionHubService
    participant MSN as MissionStatusNotifier
    participant ETS as EmergencyTrackingScreen
    
    Note over SignalR,ETS: Sự kiện Báo động Giả

    SignalR->>MHS: IncidentFalseAlarm event
    MHS->>MHS: Parse IncidentFalseAlarmData
    MHS->>MSN: Phát qua incidentFalseAlarmStream
    MSN->>MSN: Cập nhật MissionStatus.incidentFalseAlarm
    ETS->>ETS: Nhận sự kiện qua listener
    ETS->>ETS: _terminateToHome (hiển thị snackbar)
    ETS->>ETS: Ngắt MissionHub, reset state
    ETS->>ETS: Điều hướng về member_home

    Note over SignalR,ETS: Sự kiện Bàn Giao Bệnh Viện

    SignalR->>MHS: HospitalHandoverAccepted event
    MHS->>MHS: Parse HospitalHandoverAcceptedData
    MHS->>MSN: Phát qua hospitalHandoverAcceptedStream
    MSN->>MSN: Cập nhật MissionStatus.hospitalHandover*
    ETS->>ETS: Nhận sự kiện qua listener
    ETS->>ETS: _showHospitalHandoverAcceptedDialog
    ETS->>ETS: Hiển thị dialog (tên BV, số ĐT, ghi chú)
    ETS->>ETS: Sau xác nhận: _terminateToHome
    ETS->>ETS: Ngắt MissionHub, reset state
    ETS->>ETS: Điều hướng về member_home
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Snake-AID/SnakeAid.Mobile#31: Cả hai PR cùng mở rộng MissionHubService (thêm sự kiện SignalR) và mô hình DetailedIncidentData.
  • Snake-AID/SnakeAid.Mobile#64: Cả hai PR cùng thêm/mở rộng dữ liệu bàn giao bệnh viện (tên, số điện thoại, ghi chú) và tích hợp vào mô hình/luồng mission.

Poem

🐰 Một bùng nổ tín hiệu mới đến,
False alarm hay bàn giao chờ?
Stream và state nhảy múa tươi vui,
Dialog hiện lên kể chuyện bệnh viện,
Rồi về nhà, misson xong thật rồi!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/RF005-incidnet-tracking-status

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@DuongNManh
DuongNManh merged commit 3041ea4 into dev May 5, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant