From f9242b8aaf08afa11cecff9da3dea4b65a64b82b Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Mon, 30 Jun 2025 11:03:51 +0000 Subject: [PATCH] occupant information --- etl/models/conditionReport.py | 14 +++++++++++- etl/surveyedData/surveryedData.py | 38 ++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/etl/models/conditionReport.py b/etl/models/conditionReport.py index fde26f8..3eefb15 100644 --- a/etl/models/conditionReport.py +++ b/etl/models/conditionReport.py @@ -294,4 +294,16 @@ class HeatingSystem(BaseModel, table=True): heating_by_room: HeatingByRoom = Relationship() renewables_id: uuid.UUID = Field(foreign_key="renewables.id") - renewables: Renewables = Relationship() \ No newline at end of file + 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 \ No newline at end of file diff --git a/etl/surveyedData/surveryedData.py b/etl/surveyedData/surveryedData.py index 2dcdab1..8e24664 100644 --- a/etl/surveyedData/surveryedData.py +++ b/etl/surveyedData/surveryedData.py @@ -48,7 +48,8 @@ from etl.models.conditionReport import ( SecondaryHeating, HeatingByRoom, Renewables, - HeatingSystem + HeatingSystem, + Occupant ) from etl.models.topLevel import( @@ -84,7 +85,7 @@ class surveyedDataProcessor(): # [x] general_information = self.get_section_1() # [x] access_and_elevations = self.get_section_2() # [x] rooms = self.get_section_3() - # [] heating_system = self.get_section_4() + # [x] heating_system = self.get_section_4() # [] occupant_assessment = self.get_section_5() # [] site_name, reference_code, address, postcode = self.get_section_0() @@ -107,7 +108,31 @@ class surveyedDataProcessor(): access_and_elevations = self.load_access_and_elevations_from_condition_report(db_session) rooms = self.load_rooms_from_condition_report(db_session) heating_system = self.load_heating_system_from_condition_report(db_session) + occupant_assessment = self.load_occupant_info_from_condition_report(db_session) + def load_occupant_info_from_condition_report(self, db_session): + """ + occupant: Occupant + energy_use: EnergyUse + heating: HeatingFromConditionReport + shower_and_bath: ShowerAndBath + appliances: Optional[Appliances] + fridge_and_freezers: FridgeAndFreezers + cooker: Cooker + tumble_dryer: TumbleDryer + """ + self.load_occupant_information_from_condition_report(db_session) + + def load_occupant_information_from_condition_report(self, db_session): + return self.get_attribute_and_load( + self.condition_report.master_obj.occupancy_assessment, + "occupant", + Occupant, + db_session, + additional_fields={ + "landlord_wrote_that_the_tenent_agrees_assessment_been_supplied":self.condition_report.master_obj.occupancy_assessment.occupant.landlord_has_written_confirmation_that_the_tenent_agrees_to_the_assessment_been_supplied + } + ) def load_heating_system_from_condition_report(self, db_session): general_condition = self.load_general_condition_of_heating_system_from_condition_report(db_session) @@ -117,15 +142,6 @@ class surveyedDataProcessor(): heating_by_room = self.load_heating_by_room_from_condition_report(db_session) renwables = self.load_renewables_from_condition_report(db_session) - print("hello junte") - print(general_condition.id) - print(main_heating_one.id) - print(main_heating_two.id) - print(secondary_heating.id) - print(heating_by_room.id) - print(renwables.id) - print("goodbye junte") - return self.get_attribute_and_load( self.condition_report.master_obj, "heating_system",