survey-extraction/etl/models/conditionReport.py
2025-08-14 14:15:52 +00:00

386 lines
16 KiB
Python

# # SQLModel mapping for ConditionReportModel using BaseModel
# from sqlmodel import SQLModel, Field, Relationship, Column, JSON
# from typing import Optional, List
# import uuid
# from datetime import datetime
# from etl.models.topLevel import BaseModel, Documents
# class AssessorDetails(BaseModel, table=True):
# assessor_name_and_id: str
# elmhurst_id: str
# class InspectionAndProject(BaseModel, table=True):
# inspection_date: str
# class TheProperty(BaseModel, table=True):
# house_type: str
# on_which_floor_is_the_flat_located: str
# is_there_a_corridor: bool
# is_it_heated: bool
# it_there_a_balcony: bool
# classification_type: str
# orientation_front_elevation: str
# orientation_in_degrees_front_elevation: str
# exposure_zone: str
# main_wall_construction: str
# class ElevationInfo(BaseModel, table=True):
# elevation_type: str
# cavity_wall_depth: str
# is_insulation_present: bool
# insulation_type: str
# main_elevation: Optional["MainElevation"] = Relationship(back_populates="elevation_info")
# elevation_id: Optional[uuid.UUID] = Field(foreign_key="elevation.id")
# elevation_table: Optional["Elevation"] = Relationship(back_populates="info")
# class MainElevation(BaseModel, table=True):
# elevation_info_id: uuid.UUID = Field(foreign_key="elevationinfo.id")
# #SQLAlcemy things
# elevation_info: ElevationInfo = Relationship(back_populates="main_elevation")
# class Elevation(BaseModel, table=True):
# protected_conservatory_or_aonb: bool
# material_type: str
# visible_signs_of_existing_wall_insulation: str
# ground_level_bridge_the_dpc: bool
# info: List["ElevationInfo"] = Relationship(back_populates="elevation_table")
# class GeneralInformation(BaseModel, table=True):
# assessor_detail_id: uuid.UUID = Field(foreign_key="assessordetails.id")
# inspection_and_project_id: uuid.UUID = Field(foreign_key="inspectionandproject.id")
# the_property_id: uuid.UUID = Field(foreign_key="theproperty.id")
# main_elevation_id: uuid.UUID = Field(foreign_key="mainelevation.id")
# elevations_id: uuid.UUID = Field(foreign_key="elevation.id")
# assessor_details: AssessorDetails = Relationship()
# inspection_and_project: InspectionAndProject = Relationship()
# the_property: TheProperty = Relationship()
# main_elevation: MainElevation = Relationship()
# elevations: Elevation = Relationship()
# class PropertyAccess(BaseModel, table=True):
# are_there_any_road_restriction_in_the_locality: bool
# is_on_street_parking_available: bool
# are_there_any_overhead_wires_or_cables: bool
# is_the_access_gated: bool
# is_there_restricted_space_for_contractors_to_access_the_wall_area: bool
# is_there_restricted_space_for_contractors_to_access_the_roof_area: bool
# more_than_1_5_meters_in_width_to_fence_or__along_the_full_gable_elevation: bool
# is_access_to_the_rear_provided_by_use_of_a_ginnel: bool
# is_access_to_the_rear_provided_by_use_of_a_secured_alleyway: bool
# class ExternalElevation(BaseModel, table=True):
# structural_defects_of_elevation: str
# does_any_structural_defect_need_resolving_before_retrofit: bool
# any_signs_of_water_penetration_caused_by_failed_rainwater_goods_or_pipework: bool
# are_there_any_visible_signs_of_movement: bool
# are_there_any_visible_signs_of_cracking_to_the_existing_external_finish: bool
# class ExternalElevationFront(BaseModel, table=True):
# external_elevation_id: uuid.UUID = Field(foreign_key="externalelevation.id")
# external_elevation: ExternalElevation = Relationship()
# class ExternalElevationRear(BaseModel, table=True):
# do_all_answers_for_the_front_elevation_apply_to_this_wall: bool
# external_elevation_id: Optional[uuid.UUID] = Field(foreign_key="externalelevation.id")
# external_elevation: Optional[ExternalElevation] = Relationship()
# class ExternalElevationGableOne(BaseModel, table=True):
# do_all_answers_for_the_front_elevation_apply_to_this_wall: bool
# external_elevation_id: Optional[uuid.UUID] = Field(foreign_key="externalelevation.id")
# external_elevation: Optional[ExternalElevation] = Relationship()
# class ExternalElevationGableTwo(BaseModel, table=True):
# is_there_a_fourth_external_elevation: bool
# external_elevation_id: Optional[uuid.UUID] = Field(foreign_key="externalelevation.id")
# class ConservatoryOrOutbuilding(BaseModel, table=True):
# is_there_a_conservatory: bool
# is_there_a_cellar_present: bool
# is_there_an_outbuilding: bool
# class AccessAndElevations(BaseModel, table=True):
# property_access_id: uuid.UUID = Field(foreign_key="propertyaccess.id")
# external_elevation_front_id: uuid.UUID = Field(foreign_key="externalelevationfront.id")
# external_elevation_back_id: uuid.UUID = Field(foreign_key="externalelevationrear.id")
# external_elevation_gable_one_id: uuid.UUID = Field(foreign_key="externalelevationgableone.id")
# external_elevation_gable_two_id: uuid.UUID = Field(foreign_key="externalelevationgabletwo.id")
# conservatory_or_out_building_id: uuid.UUID = Field(foreign_key="conservatoryoroutbuilding.id")
# property_access: PropertyAccess = Relationship()
# external_elevation_front: ExternalElevationFront = Relationship()
# external_elevation_back: ExternalElevationRear = Relationship()
# external_elevation_gable_one: ExternalElevationGableOne = Relationship()
# external_elevation_gable_two: ExternalElevationGableTwo = Relationship()
# conservatory_or_out_building: ConservatoryOrOutbuilding = Relationship()
# class VentilationInfo(BaseModel, table=True):
# is_there_a_ventilation_system_present_in_the_room: bool
# any_damp_mould_or_excessive_condensation_within_the_room: bool
# are_there_sufficient_undercuts_on_the_closed_door: str
# is_there_any_open_flue_heating_appliances_within_the_room: bool
# class WindowsInfo(BaseModel, table=True):
# does_the_room_have_any_windows: bool
# condition_of_the_windows: Optional[str] = None
# do_the_windows_have_trickle_vents: Optional[bool] = None
# are_the_windows_openable: Optional[bool] = None
# input_trickle_vent_product_code_or_measurement: Optional[str] = None
# class RoomInfo(BaseModel, table=True):
# overall_condition_of_the_room: str
# does_the_room_have_any_defects: str
# are_there_any_sloped_ceiling_areas: Optional[bool] = None
# windows_info_id: uuid.UUID = Field(foreign_key="windowsinfo.id")
# ventilation_info_id: uuid.UUID = Field(foreign_key="ventilationinfo.id")
# windows_info: WindowsInfo = Relationship()
# ventilation_info: VentilationInfo = Relationship()
# class Hallway(BaseModel, table=True):
# is_there_a_hallway: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class LivingRoom(BaseModel, table=True):
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class DiningRoom(BaseModel, table=True):
# is_there_a_dining_room: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class Kitchen(BaseModel, table=True):
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# is_there_a_cooker_hood_present_in_the_room: bool
# class Utility(BaseModel, table=True):
# is_there_a_utility_room: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class WC(BaseModel, table=True):
# is_there_a_seperated_wc: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class Landing(BaseModel, table=True):
# is_there_a_landing: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class LoftSpace(BaseModel, table=True):
# is_the_main_loft_space_accessible: str
# is_there_more_than_one_loft_space: bool
# class RoomInRoof(BaseModel, table=True):
# is_there_a_room_in_roof: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# class Bedroom(BaseModel, table=True):
# double_or_single_bedroom: str
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# rooms_id: uuid.UUID = Field(foreign_key="rooms.id")
# rooms: Optional["Rooms"] = Relationship(back_populates="bedrooms")
# class Bathroom(BaseModel, table=True):
# is_this_an_ensuite_bathroom: bool
# room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
# room_info: Optional[RoomInfo] = Relationship()
# rooms_id: uuid.UUID = Field(foreign_key="rooms.id")
# rooms: Optional["Rooms"] = Relationship(back_populates="bathrooms")
# class Rooms(BaseModel, table=True):
# hallway_id: uuid.UUID = Field(foreign_key="hallway.id")
# hallway: Hallway = Relationship()
# living_room_id: uuid.UUID = Field(foreign_key="livingroom.id")
# living_room: LivingRoom = Relationship()
# dining_room_id: uuid.UUID = Field(foreign_key="diningroom.id")
# dining_room: DiningRoom = Relationship()
# kitchen_id: uuid.UUID = Field(foreign_key="kitchen.id")
# kitchen: Kitchen = Relationship()
# utility_id: uuid.UUID = Field(foreign_key="utility.id")
# utility: Utility = Relationship()
# wash_chamber_id: uuid.UUID = Field(foreign_key="wc.id")
# wash_chamber: WC = Relationship()
# landing_id: uuid.UUID = Field(foreign_key="landing.id")
# landing: Landing = Relationship()
# loft_space_id: uuid.UUID = Field(foreign_key="loftspace.id")
# loft_space: LoftSpace = Relationship()
# room_in_roof_id: uuid.UUID = Field(foreign_key="roominroof.id")
# room_in_roof: RoomInRoof = Relationship()
# bedrooms: List[Bedroom] = Relationship(back_populates="rooms")
# bathrooms: List[Bathroom] = Relationship(back_populates="rooms")
# class GeneralConditionHeatingSystem(BaseModel, table=True):
# is_the_heating_system_in_working_order: bool
# does_the_occupant_have_a_smart_meter: bool
# are_there_any_smart_monitoring_devices: bool
# are_the_gas_and_electricity_meters_accessible: bool
# dual_or_single_electric_meter: str
# class MainHeatingOne(BaseModel, table=True):
# as_defined_by: str
# fuel: str
# type: str
# class MainHeatingTwo(BaseModel, table=True):
# is_there_a_main_heating_two: bool
# class SecondaryHeating(BaseModel, table=True):
# is_there_a_secondary_heating: bool
# fuel: str
# electric_heating_type: str
# gas_heating_type: str
# class HeatingByRoom(BaseModel, table=True):
# rooms_heated_by_main_system_one: List[str] = Field(sa_column=Column(JSON))
# rooms_heated_by_main_system_two: List[str] = Field(sa_column=Column(JSON))
# rooms_heated_by_secondary_heating: List[str] = Field(sa_column=Column(JSON))
# are_there_any_partially_heated_rooms: bool
# partially_heated_rooms: Optional[List[str]] = Field(sa_column=Column(JSON))
# are_there_any_unheated_rooms: bool
# unheated_rooms: List[str] = Field(sa_column=Column(JSON))
# class Renewables(BaseModel, table=True):
# is_there_any_renewable_energy_system_in_place: bool
# suitable_roof_orientation_for_solar_pv_water: str
# is_there_a_water_tank: bool
# type: str
# size: str
# tank_location: str
# is_the_tank_insulated: bool
# type_of_insulation: str
# thickness_of_insulation_in_mm: int
# class HeatingSystem(BaseModel, table=True):
# general_condition_id: uuid.UUID = Field(foreign_key="generalconditionheatingsystem.id")
# general_condition: GeneralConditionHeatingSystem = Relationship()
# main_heating_one_id: uuid.UUID = Field(foreign_key="mainheatingone.id")
# main_heating_one: MainHeatingOne = Relationship()
# main_heating_two_id: uuid.UUID = Field(foreign_key="mainheatingtwo.id")
# main_heating_two: MainHeatingTwo = Relationship()
# secondary_heating_id: uuid.UUID = Field(foreign_key="secondaryheating.id")
# secondary_heating: SecondaryHeating = Relationship()
# heating_by_room_id: uuid.UUID = Field(foreign_key="heatingbyroom.id")
# heating_by_room: HeatingByRoom = Relationship()
# renewables_id: uuid.UUID = Field(foreign_key="renewables.id")
# renewables: Renewables = Relationship()
# class Occupant(BaseModel, table=True):
# name: str
# have_evidence_of_12_months_of_fuel_bill_data: bool
# total_number_of_occupants: int
# no_of_adult_occupants: int
# no_of_child_occupants: int
# no_of_occupant_of_a_pensionable_age: int
# are_there_any_vulnerable_people: bool
# is_there_anyone_with_a_disability: bool
# status_of_occupant: str
# landlord_wrote_that_the_tenent_agrees_assessment_been_supplied: bool
# class EnergyUse(BaseModel, table=True):
# property_tenure: str
# who_is_the_electricity_payer: str
# class HeatingFromConditionReport(BaseModel, table=True):
# room_stat_in_temperature_in_celsius: Optional[str] = None
# room_stat_location: Optional[str] = None
# is_the_heating_pattern_known: Optional[str] = None
# class ShowerAndBath(BaseModel, table=True):
# shower_type: str
# do_you_know_the_no_of_showers_per_day_per_week: bool
# please_input_no_of_showers_and_specify_a_day_or_a_week: str
# do_you_know_the_number_of_baths_per_day_or_per_week: str
# class FridgeAndFreezers(BaseModel, table=True):
# no_of_stand_alone_seperate_fridges: int
# no_of_stand_alone_seperate_freezers: int
# no_of_stand_alone_or_integrated_fridge_freezers: int
# class Cooker(BaseModel,table=True):
# range_fuel: str
# normal_large_range: str
# cooker_type: str
# class TumbleDryer(BaseModel, table=True):
# percentage_of_annual_use: int
# space_for_outdoor_drying: bool
# class OccupantAssessment(BaseModel, table=True):
# occupant_id: uuid.UUID = Field(foreign_key="occupant.id")
# occupant: Occupant = Relationship()
# energy_use_id: uuid.UUID = Field(foreign_key="energyuse.id")
# energy_use: EnergyUse = Relationship()
# heating_id: uuid.UUID = Field(foreign_key="heatingfromconditionreport.id")
# heating: HeatingFromConditionReport = Relationship()
# shower_and_bath_id: uuid.UUID = Field(foreign_key="showerandbath.id")
# shower_and_bath: ShowerAndBath = Relationship()
# # appliances: Optional[Appliances]
# # appliances_id
# fridge_and_freezers_id: uuid.UUID = Field(foreign_key="fridgeandfreezers.id")
# fridge_and_freezers: FridgeAndFreezers = Relationship()
# cooker_id: uuid.UUID = Field(foreign_key="cooker.id")
# cooker: Cooker = Relationship()
# tumble_dryer_id: uuid.UUID = Field(foreign_key="tumbledryer.id")
# tumble_dryer: TumbleDryer = Relationship()
# class ConditionReportModel(BaseModel, table=True):
# project_site_name: str
# property_reference_code: str
# property_address: str
# postcode: str
# general_information_id: uuid.UUID = Field(foreign_key="generalinformation.id")
# general_information: GeneralInformation = Relationship()
# access_and_elevations_id: uuid.UUID = Field(foreign_key="accessandelevations.id")
# access_and_elevations: AccessAndElevations = Relationship()
# rooms_id: uuid.UUID = Field(foreign_key="rooms.id")
# rooms: Rooms = Relationship()
# heating_system_id: uuid.UUID = Field(foreign_key="heatingsystem.id")
# heating_system: HeatingSystem = Relationship()
# occupancy_assessment_id: uuid.UUID = Field(foreign_key="occupantassessment.id")
# occupancy_assessment: OccupantAssessment = Relationship()