schemas.py 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from pydantic import BaseModel, Field
  2. from typing import List, Optional, Union, Dict
  3. from uuid import UUID
  4. from datetime import datetime
  5. class UserAccount(BaseModel):
  6. id: str = Field(description="Unique identifier for the user.")
  7. name: str = Field(description="Full name of the employee.")
  8. department: str = Field(description="Department name.")
  9. medical_allowance: float = Field(description="Remaining annual medical allowance in MYR.")
  10. class ExtractionResponse(BaseModel):
  11. provider_name: str = Field(description="The name of the clinic or hospital.")
  12. visit_date: str = Field(description="The date of service in YYYY-MM-DD format.")
  13. total_amount: float = Field(description="The total amount paid.")
  14. currency: str = Field(description="3-letter currency code (e.g. USD, SGD).")
  15. items: List[str] = Field(description="Simplified list of services (e.g. 'Consultation', 'Medicine').")
  16. confidence_score: float = Field(description="Model's confidence from 0.0 to 1.0.")
  17. needs_manual_review: bool = Field(description="Set to true if text is blurry or data is ambiguous.")
  18. ai_reasoning: str = Field(description="A brief explanation of how the data was identified.")
  19. receipt_ref_no: Optional[str] = Field(default=None, description="The reference number or invoice number on the receipt.")
  20. clinic_reg_no: Optional[str] = Field(default=None, description="The clinic's official registration number (SSM/MOH).")
  21. claim_category: Optional[str] = Field(default=None, description="Category: General, Dental, Optical, Specialist.")
  22. diagnosis_brief: Optional[str] = Field(default=None, description="A very short summary of the diagnosis or items seen.")
  23. class ClaimSubmission(BaseModel):
  24. provider_name: str = Field(description="The name of the clinic or hospital.")
  25. visit_date: str = Field(description="The date of service in YYYY-MM-DD format.")
  26. amount_spent: float = Field(description="The manual or validated total amount spent.")
  27. currency: str = Field(description="3-letter currency code (e.g. USD, MYR).")
  28. treatment_type: str = Field(description="Type of treatment (Outpatient, Dental, etc.).")
  29. cost_center: str = Field(description="Internal cost center code.")
  30. declaration_signed: bool = Field(description="Whether the user signed the compliance declaration.")
  31. extraction_data: Optional[ExtractionResponse] = Field(default=None, description="Optional AI extraction data if used.")
  32. class ClaimRecord(BaseModel):
  33. id: str = Field(description="Unique identifier for the claim record.")
  34. timestamp: str = Field(description="ISO format timestamp of submission.")
  35. submitted_by: str = Field(description="Name of the user who submitted the claim.")
  36. department: str = Field(description="Department of the user.")
  37. amount_spent: float = Field(description="The raw total amount from the form/receipt.")
  38. amount_claimed: float = Field(description="The actual amount credited after policy capping.")
  39. provider_name: str = Field(description="The name of the clinic or hospital.")
  40. visit_date: str = Field(description="The date of service in YYYY-MM-DD format.")
  41. treatment_type: str = Field(description="Type of treatment.")
  42. cost_center: str = Field(description="Internal cost center code.")
  43. declaration_signed: bool = Field(description="Whether the user signed the compliance declaration.")
  44. extraction_data: Optional[ExtractionResponse] = Field(default=None, description="The optional AI-extracted data for this claim.")
  45. class V2TemplateRequest(BaseModel):
  46. template_fields: dict[str, str] = Field(description="Mapping of field keys to their descriptions/instructions.")
  47. user_name: Optional[str] = "Demo User"
  48. department: Optional[str] = "Operations"
  49. class V2Field(BaseModel):
  50. key: str = Field(description="The field name from the template.")
  51. value: Optional[Union[str, float]] = Field(description="The extracted value or null if not found.")
  52. class V2TemplateResponse(BaseModel):
  53. filled_data: List[V2Field] = Field(description="The list of filled form values where keys match the template.")
  54. unfilled_fields: List[str] = Field(description="Fields from the template that could not be found in the image.")