Skip to content

Commit 0babec6

Browse files
committed
Handle correct and incorrect Screen Or Assess headings
1 parent b8509c7 commit 0babec6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

manage_breast_screening/notifications/management/commands/create_appointments.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def update_or_create_appointment(
125125
booked_at=self.workflow_action_date_and_time(
126126
row["Action Timestamp"]
127127
),
128-
assessment=(row["Screen or Asses"] == "A"),
128+
assessment=self.is_assessment(row),
129129
),
130130
True,
131131
)
@@ -163,6 +163,16 @@ def workflow_action_date_and_time(self, timestamp: str) -> datetime:
163163
dt = datetime.strptime(timestamp, "%Y%m%d-%H%M%S")
164164
return dt.replace(tzinfo=TZ_INFO)
165165

166+
def is_assessment(self, row: pandas.Series) -> bool:
167+
"""
168+
There was an error in the data where the column was initially misspelled as 'Screen or Asses'. To ensure backwards compatibility, we check for both spellings.
169+
"""
170+
if "Screen or Assess" in row:
171+
return row["Screen or Assess"] == "A"
172+
elif "Screen or Asses" in row:
173+
return row["Screen or Asses"] == "A"
174+
return False
175+
166176
def appointment_date_and_time(self, row: pandas.Series) -> datetime:
167177
dt = datetime.strptime(
168178
f"{row['Appt Date']} {row['Appt Time']}",

0 commit comments

Comments
 (0)