@@ -113,19 +113,26 @@ def update_or_create_appointment(
113113 nbss_id = row ["Appointment ID" ],
114114 nhs_number = row ["NHS Num" ],
115115 number = row ["Screen Appt num" ],
116- batch_id = row . get ("Batch ID" , row . get ( "BatchID" ) ),
116+ batch_id = self . handle_aliased_column ("Batch ID" , "BatchID" , row ),
117117 clinic = clinic ,
118118 episode_started_at = datetime .strptime (
119119 row ["Episode Start" ], "%Y%m%d"
120120 ).replace (tzinfo = TZ_INFO ),
121- episode_type = row .get ("Episode Type" , row .get ("Epsiode Type" )),
121+ episode_type = self .handle_aliased_column (
122+ "Episode Type" , "Epsiode Type" , row
123+ ),
122124 starts_at = self .appointment_date_and_time (row ),
123125 status = row ["Status" ],
124126 booked_by = row ["Booked By" ],
125127 booked_at = self .workflow_action_date_and_time (
126128 row ["Action Timestamp" ]
127129 ),
128- assessment = (row ["Screen or Asses" ] == "A" ),
130+ assessment = (
131+ self .handle_aliased_column (
132+ "Screen or Assess" , "Screen or Asses" , row
133+ )
134+ == "A"
135+ ),
129136 ),
130137 True ,
131138 )
@@ -163,6 +170,11 @@ def workflow_action_date_and_time(self, timestamp: str) -> datetime:
163170 dt = datetime .strptime (timestamp , "%Y%m%d-%H%M%S" )
164171 return dt .replace (tzinfo = TZ_INFO )
165172
173+ def handle_aliased_column (
174+ self , expected_name : str , fallback_name : str , row : pandas .Series
175+ ) -> object :
176+ return row .get (expected_name , row .get (fallback_name ))
177+
166178 def appointment_date_and_time (self , row : pandas .Series ) -> datetime :
167179 dt = datetime .strptime (
168180 f"{ row ['Appt Date' ]} { row ['Appt Time' ]} " ,
0 commit comments