-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpropertyclaim.py
More file actions
364 lines (314 loc) · 12.2 KB
/
Copy pathpropertyclaim.py
File metadata and controls
364 lines (314 loc) · 12.2 KB
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
from __future__ import annotations
from typing import List, Optional
from pydantic import BaseModel, Field
class Address(BaseModel):
"""
A class representing an address.
Attributes:
street: Street address
city: City, e.g. New York
state: State, e.g. NY
postal_code: Postal code, e.g. 10001
country: Country, e.g. USA
"""
street: Optional[str] = Field(description="Street address, e.g. 123 Main St.")
city: Optional[str] = Field(description="City, e.g. New York")
state: Optional[str] = Field(description="State, e.g. NY")
postal_code: Optional[str] = Field(description="Postal code, e.g. 10001")
country: Optional[str] = Field(description="Country, e.g. USA")
@staticmethod
def example():
"""
Creates an empty example Address object.
Returns:
Address: An empty Address object.
"""
return Address(street="", city="", state="", postal_code="", country="")
def to_dict(self):
"""
Converts the Address object to a dictionary.
Returns:
dict: The Address object as a dictionary.
"""
return {
"street": self.street,
"city": self.city,
"state": self.state,
"postal_code": self.postal_code,
"country": self.country,
}
class PolicyClaimInfo(BaseModel):
"""
A class representing policy and claim information.
Attributes:
first_name: First name of the policy holder.
last_name: Last name of the policy holder.
telephone_number: Telephone number of the policy holder.
policy_number: Policy number.
coverage_type: Type of coverage.
claim_number: Claim number.
policy_effective_date: Policy effective date.
policy_expiration_date: Policy expiration date.
damage_deductible: Damage deductible.
date_of_damage_loss: Date of damage/loss.
time_of_loss: Time of loss.
date_prepared: Date prepared.
property_address: Address of the property.
mailing_address: Mailing address.
"""
first_name: Optional[str] = Field(description="First name of the policy holder")
last_name: Optional[str] = Field(description="Last name of the policy holder")
telephone_number: Optional[str] = Field(
description="Telephone number of the policy holder"
)
policy_number: Optional[str] = Field(description="Policy number")
coverage_type: Optional[str] = Field(description="Type of coverage")
claim_number: Optional[str] = Field(description="Claim number")
policy_effective_date: Optional[str] = Field(
description="Policy effective date, e.g. 2023-01-01"
)
policy_expiration_date: Optional[str] = Field(
description="Policy expiration date, e.g. 2024-01-01"
)
damage_deductible: Optional[float] = Field(
description="Damage deductible e.g. 500.0"
)
damage_deductible_currency: Optional[str] = Field(
description="Currency of the damage deductible e.g. USD, just in case it can't be extracted, the value should be got by GPT from Policyholder's Property Address"
)
date_of_damage_loss: Optional[str] = Field(
description="Date of damage/loss e.g. 2023-01-01"
)
time_of_loss: Optional[str] = Field(description="Time of loss e.g. 14:30")
date_prepared: Optional[str] = Field(description="Date prepared e.g. 2023-01-01")
property_address: Optional[Address] = Field(
description="Address of the property e.g. 123 Main St., City, Country"
)
mailing_address: Optional[Address] = Field(
description="Mailing address e.g. 456 Elm St., City, Country"
)
@staticmethod
def example():
"""
Creates an empty example PolicyClaimInfo object.
Returns:
PolicyClaimInfo: An empty PolicyClaimInfo object.
"""
return PolicyClaimInfo(
first_name="",
last_name="",
telephone_number="",
policy_number="",
coverage_type="",
claim_number="",
policy_effective_date="",
policy_expiration_date="",
damage_deductible=0.0,
damage_deductible_currency="",
date_of_damage_loss="",
time_of_loss="",
date_prepared="",
property_address=Address.example(),
mailing_address=Address.example(),
)
def to_dict(self):
"""
Converts the PolicyClaimInfo object to a dictionary.
Returns:
dict: The PolicyClaimInfo object as a dictionary.
"""
return {
"first_name": self.first_name,
"last_name": self.last_name,
"telephone_number": self.telephone_number,
"policy_number": self.policy_number,
"coverage_type": self.coverage_type,
"claim_number": self.claim_number,
"policy_effective_date": self.policy_effective_date,
"policy_expiration_date": self.policy_expiration_date,
"damage_deductible": self.damage_deductible,
"damage_deductible_currency": self.damage_deductible_currency,
"date_of_damage_loss": self.date_of_damage_loss,
"time_of_loss": self.time_of_loss,
"date_prepared": self.date_prepared,
"property_address": self.property_address.to_dict()
if self.property_address
else None,
"mailing_address": self.mailing_address.to_dict()
if self.mailing_address
else None,
}
class PropertyClaimDetails(BaseModel):
"""
A class representing property claim details.
Attributes:
item: Item name.
description: Description of the item.
date_acquired: Date the item was acquired.
cost_new: Cost of the item when new.
cost_new_currency: Currency of the cost new.
replacement_repair: Replacement or repair cost.
replacement_repair_currency: Currency of the replacement/repair cost.
"""
item: Optional[str] = Field(description="Item name")
description: Optional[str] = Field(description="Description of the item")
date_acquired: Optional[str] = Field(
description="Date the item was acquired e.g. 2023-01-01"
)
cost_new: Optional[float] = Field(
description="Cost of the item when new e.g. 1000.0"
)
cost_new_currency: Optional[str] = Field(
description="Currency of the cost new e.g. USD. just in case it can't be extracted, the value should be got by GPT from Policyholder's Property Address"
)
replacement_repair: Optional[float] = Field(
description="Replacement or repair cost e.g. 500.0."
)
replacement_repair_currency: Optional[str] = Field(
description="Currency of the replacement/repair cost e.g. USD, just in case it can't be extracted, the value should be got by GPT from Policyholder's Property Address"
)
@staticmethod
def example():
"""
Creates an empty example PropertyClaimDetails object.
Returns:
PropertyClaimDetails: An empty PropertyClaimDetails object.
"""
return PropertyClaimDetails(
item="",
description="",
date_acquired="",
cost_new=0.0,
cost_new_currency="",
replacement_repair=0.0,
replacement_repair_currency="",
)
def to_dict(self):
"""
Converts the PropertyClaimDetails object to a dictionary.
Returns:
dict: The PropertyClaimDetails object as a dictionary.
"""
return {
"item": self.item,
"description": self.description,
"date_acquired": self.date_acquired,
"cost_new": self.cost_new,
"cost_new_currency": self.cost_new_currency,
"replacement_repair": self.replacement_repair,
"replacement_repair_currency": self.replacement_repair_currency,
}
class Signature(BaseModel):
"""
A class representing a signature for an invoice.
Attributes:
signatory: Name of the person who signed the invoice.
is_signed: Indicates if the invoice is signed.
"""
signatory: Optional[str] = Field(
description="Name of the person who signed the invoice"
)
is_signed: Optional[bool] = Field(
description="Indicates if the invoice is signed. GPT should check whether it has signature in image files. if there is Sign, fill it up as True"
)
@staticmethod
def example():
"""
Creates an empty example InvoiceSignature object.
Returns:
InvoiceSignature: An empty InvoiceSignature object.
"""
return Signature(signatory="", is_signed=False)
def to_dict(self):
"""
Converts the InvoiceSignature object to a dictionary.
Returns:
dict: The InvoiceSignature object as a dictionary.
"""
return {"signatory": self.signatory, "is_signed": self.is_signed}
class ClaimsDisclaimer(BaseModel):
"""
A class representing claims disclaimer.
When Text values in the fields has some noise characters, it should be removed by GPT.
For example, "Apple Computer\" should be "Apple Computer".
Attributes:
disclaimer: Disclaimer information.
policyholder_signature: Signature of the policyholder.
date: Date of the signature.
"""
disclaimer: Optional[str] = Field(description="Disclaimer information")
policyholder_signature: Optional[Signature] = Field(
description="Signature of the policyholder"
)
date: Optional[str] = Field(description="Date of the signature e.g. 2023-01-01")
@staticmethod
def example():
"""
Creates an empty example ClaimsDisclaimer object.
Returns:
ClaimsDisclaimer: An empty ClaimsDisclaimer object.
"""
return ClaimsDisclaimer(
disclaimer="",
policyholder_signature=Signature.example(),
date="",
)
def to_dict(self):
"""
Converts the ClaimsDisclaimer object to a dictionary.
Returns:
dict: The ClaimsDisclaimer object as a dictionary.
"""
return {
"disclaimer": self.disclaimer,
"policyholder_signature": self.policyholder_signature,
"date": self.date,
}
class PropertyLossDamageClaimForm(BaseModel):
"""
A class representing a property loss or damage claim form.
Attributes:
policy_claim_info: Policy and claim information.
property_claim_details: List of property claim details.
claims_disclaimer: Claims disclaimer information.
"""
policy_claim_info: Optional[PolicyClaimInfo] = Field(
description="Policy and claim information"
)
property_claim_details: Optional[List[PropertyClaimDetails]] = Field(
description="List of property claim details"
)
claims_disclaimer: Optional[ClaimsDisclaimer] = Field(
description="Claims disclaimer information"
)
@staticmethod
def example():
"""
Creates an empty example PropertyLossDamageClaimForm object.
Returns:
PropertyLossDamageClaimForm: An empty PropertyLossDamageClaimForm object.
"""
return PropertyLossDamageClaimForm(
policy_claim_info=PolicyClaimInfo.example(),
property_claim_details=[PropertyClaimDetails.example()],
claims_disclaimer=ClaimsDisclaimer.example(),
)
def to_dict(self):
"""
Converts the PropertyLossDamageClaimForm object to a dictionary.
Returns:
dict: The PropertyLossDamageClaimForm object as a dictionary.
"""
return {
"policy_claim_info": self.policy_claim_info.to_dict()
if self.policy_claim_info
else None,
"property_claim_details": [
detail.to_dict() for detail in self.property_claim_details
]
if self.property_claim_details
else [],
"claims_disclaimer": self.claims_disclaimer.to_dict()
if self.claims_disclaimer
else None,
}