File size: 7,317 Bytes
20bdfba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
from pydantic import BaseModel, Field
from typing import Literal, List, Union, Optional

# Base class for CircumstanceType with a discriminator field 'type'
class CircumstanceTypeBase(BaseModel):
    type: str

# Collision with means of transport
class RoadVehicleCollision(CircumstanceTypeBase):
    type: Literal['road_vehicle']
    infrastructure_number: Optional[str] = None
    road_type: Literal['highway', 'main road', 
                       'secondary road', 'local road/path/trail', 
                       'parking lot']

class TrainCollision(CircumstanceTypeBase):
    type: Literal['train']
    infrastructure_number: str

class AircraftCollision(CircumstanceTypeBase):
    type: Literal['aircraft']

class BoatCollision(CircumstanceTypeBase):
    type: Literal['boat']

class OtherTransportCollision(CircumstanceTypeBase):
    type: Literal['other transport collision']

class UnknownTransportCollision(CircumstanceTypeBase):
    type: Literal['unknown transport collision']

# Destruction / Deliberately removed
class HuntingDestruction(CircumstanceTypeBase):
    type: Literal['hunting']
    method: Literal['shooting', 'bow', 'falconry', 
                    'hounds hunting', 'digging up', 
                    "other hunting", "unknow hunting"]

class TrapDestruction(CircumstanceTypeBase):
    type: Literal['trap']
    method: Literal['killing trap', 'pole trap', 'trap cage', 'corvids nasse', 
                    'net', 'cage trap', 'fall-trap', 'glue trap', 'insect trap', 
                    "other trap", "unknown trap"]

class PoisoningDestruction(CircumstanceTypeBase):
    type: Literal['poisoning']

class RemovalDestruction(CircumstanceTypeBase):
    type: Literal['removal or direct capture']
    method: Literal['gassing', 'raptor captured at nest', 'brood destruction', 
                    'traffic/trade', 'capture accident', 'scientific sample',
                    "other removal", "unknown removal"]

class FishingDestruction(CircumstanceTypeBase):
    type: Literal['fishing']
    method: Literal['drowned/tangled', 'beached with capture indications', "other fishing", "unknown fishing"]

class OtherDestruction(CircumstanceTypeBase):
    type: Literal['other destruction']

class UnknownDestruction(CircumstanceTypeBase):
    type: Literal['unknown destruction']

# Indirect destruction
class PylonElectricGridDestruction(CircumstanceTypeBase):
    type: Literal['pylone and electric grid']
    infrastructure: Literal['electric line', 'pole/pylon', "other structure", "unknown structure"]
    cause: Literal['collision', 'electrocution']

class WindfarmDestruction(CircumstanceTypeBase):
    type: Literal['windfarm']

class OtherCollisionDestruction(CircumstanceTypeBase):
    type: Literal['other collision']
    object: Literal['window', 'building', 'lighthouse', 
                    'cable', 'wire fence/barbed wire', 'other crash', 'unknown crash']

class FallDestruction(CircumstanceTypeBase):
    type: Literal['fall']
    location: Literal['chimney', 'empty pole', 'hole/well', 'other fall', 'unknown fall']

class DevelopmentWorkDestruction(CircumstanceTypeBase):
    type: Literal['development work']
    work_type: Literal['transport infrastructure', 'building', 'other work', 'unknown work']

class PollutionContaminationDestruction(CircumstanceTypeBase):
    type: Literal['pollution / contamination']
    pollution_type: Literal['oil pollution', 'chemical pollution', 'heavy metals', 
                            'light', 'noise', 
                            'plastic ingestion', 'other pollution', 'unknown pollution']

class AgriculturalNetProtectionDestruction(CircumstanceTypeBase):
    type: Literal['agricultural net protection']

class VegetalForestWorkDestruction(CircumstanceTypeBase):
    type: Literal['vegetal / forest work']
    work_type: Literal['clearing/mowing/plowing', 'tree felling/pruning', 
                       'other forest work', 'unknown forest work']

class OtherIndirectDestruction(CircumstanceTypeBase):
    type: Literal['other indirect desctruction']

class UnknownIndirectDestruction(CircumstanceTypeBase):
    type: Literal['unknown indirect desctruction']

# Natural cause
class Predation(CircumstanceTypeBase):
    type: Literal['predation']
    predator: Literal['cat', 'dog', 'rooster/hen', 
                      'other domestic animal', 'wild birds', 
                      'wild mammal', 'other predator', 'unknown predator']

class Weather(CircumstanceTypeBase):
    type: Literal['weather']
    condition: Literal['cold wave', 'drought', 'hail', 
                       'lightening', 'storm', 
                       'other weather', 'unknown weather']

class NaturalDisaster(CircumstanceTypeBase):
    type: Literal['natural disaster']
    disaster: Literal['fire', 'avalanche', 'rock fall', 
                      'mudslide', 'volcanic eruption/ashes', 
                      'other natural disaster', 'unknown natural disaster']

class NestFall(CircumstanceTypeBase):
    type: Literal['nest fall']

class StrandingExhaustion(CircumstanceTypeBase):
    type: Literal['stranding due to exhaustion']

class DiseaseParasite(CircumstanceTypeBase):
    type: Literal['disease/parasite']

class AccidentalDrowning(CircumstanceTypeBase):
    type: Literal['accidental drowning']
    drowning_location: Literal['drinking trough', 'pool', 
                               'storm pool', 'irrigation pool', 
                               'natural pool', 'flood', 
                               'other location', 'unknown location']

class OtherNaturalCause(CircumstanceTypeBase):
    type: Literal['other natural cause']

class UnknownNaturalCause(CircumstanceTypeBase):
    type: Literal['unknown natural cause']

# Unknown cause
class UnknownCircumstance(CircumstanceTypeBase):
    type: Literal['unknown']

# Union of all possible CircumstanceTypes with 'type' as the discriminator
CircumstanceType = Union[
    RoadVehicleCollision,
    TrainCollision,
    AircraftCollision,
    BoatCollision,
    OtherTransportCollision,
    UnknownTransportCollision,
    HuntingDestruction,
    TrapDestruction,
    PoisoningDestruction,
    RemovalDestruction,
    FishingDestruction,
    OtherDestruction,
    UnknownDestruction,
    PylonElectricGridDestruction,
    WindfarmDestruction,
    OtherCollisionDestruction,
    FallDestruction,
    DevelopmentWorkDestruction,
    PollutionContaminationDestruction,
    AgriculturalNetProtectionDestruction,
    VegetalForestWorkDestruction,
    OtherIndirectDestruction,
    UnknownIndirectDestruction,
    Predation,
    Weather,
    NaturalDisaster,
    NestFall,
    StrandingExhaustion,
    DiseaseParasite,
    AccidentalDrowning,
    OtherNaturalCause,
    UnknownNaturalCause,
    UnknownCircumstance
]

# Main Circumstance class
class Circumstances(BaseModel):
    circumstance_radio: str  # e.g., "Yes"
    circumstance: Optional[str] = None  # e.g., "COLLISION"
    circumstance_type: Optional[CircumstanceType] = Field(None, discriminator='type')


# Example usage
# json_data = {
#     "circumstance": "COLLISION",
#     "circumstance_radio": "Yes",
#     "circumstance_type": {
#         "type": "Train",
#         "infrastructure_number": "56"
#     }
# }
# circumstance_instance = Circumstance(**json_data)
# circumstance_schema = Circumstance.schema_json(indent=2)