Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix appointments.status mapping #1785

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ehrql/backends/tpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ def modify_query_variables(self, variables):
WHEN 4 THEN 'Finished' COLLATE Latin1_General_CI_AS
WHEN 5 THEN 'Requested' COLLATE Latin1_General_CI_AS
WHEN 6 THEN 'Blocked' COLLATE Latin1_General_CI_AS
WHEN 7 THEN 'Visit' COLLATE Latin1_General_CI_AS
WHEN 8 THEN 'Waiting' COLLATE Latin1_General_CI_AS
WHEN 9 THEN 'Cancelled by Patient' COLLATE Latin1_General_CI_AS
WHEN 10 THEN 'Cancelled by Unit' COLLATE Latin1_General_CI_AS
WHEN 11 THEN 'Cancelled by Other Service' COLLATE Latin1_General_CI_AS
WHEN 12 THEN 'No Access Visit' COLLATE Latin1_General_CI_AS
WHEN 13 THEN 'Cancelled Due To Death' COLLATE Latin1_General_CI_AS
WHEN 14 THEN 'Patient Walked Out' COLLATE Latin1_General_CI_AS
WHEN 8 THEN 'Visit' COLLATE Latin1_General_CI_AS
WHEN 9 THEN 'Waiting' COLLATE Latin1_General_CI_AS
WHEN 10 THEN 'Cancelled by Patient' COLLATE Latin1_General_CI_AS
WHEN 11 THEN 'Cancelled by Unit' COLLATE Latin1_General_CI_AS
WHEN 12 THEN 'Cancelled by Other Service' COLLATE Latin1_General_CI_AS
WHEN 14 THEN 'No Access Visit' COLLATE Latin1_General_CI_AS
WHEN 15 THEN 'Cancelled Due To Death' COLLATE Latin1_General_CI_AS
WHEN 16 THEN 'Patient Walked Out' COLLATE Latin1_General_CI_AS
END AS status
FROM Appointment
"""
Expand Down
64 changes: 60 additions & 4 deletions tests/integration/backends/test_tpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,35 +416,91 @@ def test_apcs_cost_historical(select_all):
def test_appointments(select_all):
results = select_all(
Patient(Patient_ID=1),
Appointment(
Patient_ID=1,
BookedDate="2021-01-01T09:00:00",
StartDate="2021-01-01T09:00:00",
SeenDate="9999-12-31T00:00:00",
Status=1,
),
Appointment(
Patient_ID=1,
BookedDate="2021-01-01T09:00:00",
StartDate="2021-01-01T09:00:00",
SeenDate="9999-12-31T00:00:00",
Status=3,
),
Appointment(
Patient_ID=1,
BookedDate="2021-01-01T09:00:00",
StartDate="2021-01-01T09:00:00",
SeenDate="2021-01-01T09:00:00",
Status=5,
Status=4,
),
Appointment(
Patient_ID=1,
BookedDate="2021-01-02T09:00:00",
StartDate="2021-01-02T09:00:00",
SeenDate="9999-12-31T00:00:00",
Status=5,
Status=9,
),
Appointment(
Patient_ID=1,
BookedDate="2021-01-03T09:00:00",
StartDate="2021-01-03T09:00:00",
SeenDate="2021-01-03T09:00:00",
Status=8,
),
Appointment(
Patient_ID=1,
BookedDate="2021-01-04T09:00:00",
StartDate="2021-01-04T09:00:00",
SeenDate="2021-01-04T09:00:00",
Status=16,
),
)
assert results == [
{
"patient_id": 1,
"booked_date": date(2021, 1, 1),
"start_date": date(2021, 1, 1),
"seen_date": None,
"status": "Arrived",
},
{
"patient_id": 1,
"booked_date": date(2021, 1, 1),
"start_date": date(2021, 1, 1),
"seen_date": None,
"status": "In Progress",
},
{
"patient_id": 1,
"booked_date": date(2021, 1, 1),
"start_date": date(2021, 1, 1),
"seen_date": date(2021, 1, 1),
"status": "Requested",
"status": "Finished",
},
{
"patient_id": 1,
"booked_date": date(2021, 1, 2),
"start_date": date(2021, 1, 2),
"seen_date": None,
"status": "Requested",
"status": "Waiting",
},
{
"patient_id": 1,
"booked_date": date(2021, 1, 3),
"start_date": date(2021, 1, 3),
"seen_date": date(2021, 1, 3),
"status": "Visit",
},
{
"patient_id": 1,
"booked_date": date(2021, 1, 4),
"start_date": date(2021, 1, 4),
"seen_date": date(2021, 1, 4),
"status": "Patient Walked Out",
},
]

Expand Down