File size: 4,188 Bytes
4d0ffdd
 
 
 
 
 
f6c65ef
4d0ffdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6c65ef
4d0ffdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
 
 
f6c65ef
4d0ffdd
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
f6c65ef
4d0ffdd
 
f6c65ef
4d0ffdd
 
 
 
f6c65ef
4d0ffdd
 
 
f6c65ef
4d0ffdd
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
"""Hearing event entity and outcome tracking.

This module defines the Hearing class which represents a scheduled court hearing
with its outcome and associated metadata.
"""

from dataclasses import dataclass
from datetime import date
from enum import Enum
from typing import Optional


class HearingOutcome(Enum):
    """Possible outcomes of a hearing."""
    SCHEDULED = "SCHEDULED"       # Future hearing
    HEARD = "HEARD"               # Completed successfully
    ADJOURNED = "ADJOURNED"       # Postponed
    DISPOSED = "DISPOSED"         # Case concluded
    NO_SHOW = "NO_SHOW"           # Party absent
    WITHDRAWN = "WITHDRAWN"       # Case withdrawn


@dataclass
class Hearing:
    """Represents a scheduled court hearing event.

    Attributes:
        hearing_id: Unique identifier
        case_id: Associated case
        scheduled_date: Date of hearing
        courtroom_id: Assigned courtroom
        judge_id: Presiding judge
        stage: Case stage at time of hearing
        outcome: Result of hearing
        actual_date: Actual date if rescheduled
        duration_minutes: Estimated duration
        notes: Optional notes
    """
    hearing_id: str
    case_id: str
    scheduled_date: date
    courtroom_id: int
    judge_id: str
    stage: str
    outcome: HearingOutcome = HearingOutcome.SCHEDULED
    actual_date: Optional[date] = None
    duration_minutes: int = 30
    notes: Optional[str] = None

    def mark_as_heard(self, actual_date: Optional[date] = None) -> None:
        """Mark hearing as successfully completed.

        Args:
            actual_date: Actual date if different from scheduled
        """
        self.outcome = HearingOutcome.HEARD
        self.actual_date = actual_date or self.scheduled_date

    def mark_as_adjourned(self, reason: str = "") -> None:
        """Mark hearing as adjourned.

        Args:
            reason: Reason for adjournment
        """
        self.outcome = HearingOutcome.ADJOURNED
        if reason:
            self.notes = reason

    def mark_as_disposed(self) -> None:
        """Mark hearing as final disposition."""
        self.outcome = HearingOutcome.DISPOSED
        self.actual_date = self.scheduled_date

    def mark_as_no_show(self, party: str = "") -> None:
        """Mark hearing as no-show.

        Args:
            party: Which party was absent
        """
        self.outcome = HearingOutcome.NO_SHOW
        if party:
            self.notes = f"No show: {party}"

    def reschedule(self, new_date: date) -> None:
        """Reschedule hearing to a new date.

        Args:
            new_date: New scheduled date
        """
        self.scheduled_date = new_date
        self.outcome = HearingOutcome.SCHEDULED

    def is_complete(self) -> bool:
        """Check if hearing has concluded.

        Returns:
            True if outcome is not SCHEDULED
        """
        return self.outcome != HearingOutcome.SCHEDULED

    def is_successful(self) -> bool:
        """Check if hearing was successfully held.

        Returns:
            True if outcome is HEARD or DISPOSED
        """
        return self.outcome in (HearingOutcome.HEARD, HearingOutcome.DISPOSED)

    def get_effective_date(self) -> date:
        """Get actual or scheduled date.

        Returns:
            actual_date if set, else scheduled_date
        """
        return self.actual_date or self.scheduled_date

    def __repr__(self) -> str:
        return (f"Hearing(id={self.hearing_id}, case={self.case_id}, "
                f"date={self.scheduled_date}, outcome={self.outcome.value})")

    def to_dict(self) -> dict:
        """Convert hearing to dictionary for serialization."""
        return {
            "hearing_id": self.hearing_id,
            "case_id": self.case_id,
            "scheduled_date": self.scheduled_date.isoformat(),
            "actual_date": self.actual_date.isoformat() if self.actual_date else None,
            "courtroom_id": self.courtroom_id,
            "judge_id": self.judge_id,
            "stage": self.stage,
            "outcome": self.outcome.value,
            "duration_minutes": self.duration_minutes,
            "notes": self.notes,
        }