Skip to content

Commit

Permalink
Added APCS discharge_method
Browse files Browse the repository at this point in the history
  • Loading branch information
rw251 committed Jan 30, 2025
1 parent 2fa95e5 commit b101662
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions ehrql/backends/tpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def apcs(self):
apcs.Admission_Date AS admission_date,
apcs.Discharge_Date AS discharge_date,
apcs.Discharge_Destination as discharge_destination,
apcs.Discharge_Method as discharge_method,
apcs.Spell_Core_HRG_SUS AS spell_core_hrg_sus,
apcs.Admission_Method AS admission_method,
apcs.Der_Diagnosis_All AS all_diagnoses,
Expand Down
10 changes: 10 additions & 0 deletions ehrql/tables/tpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ class apcs(EventFrame):
"for a full list of codes."
),
)
discharge_method = Series(
str,
description=(
"The method of discharge from a hospital provider spell. "
"Currently the code is a 1 character string (e.g. 1 = discharged on clinical advice, "
"4 = died). "
"Refer to [this documentation](https://www.datadictionary.nhs.uk/attributes/discharge_method.html) "
"for a full list of codes."
),
)
spell_core_hrg_sus = Series(
str,
description=(
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/backends/test_tpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def test_apcs(select_all_tpp):
Admission_Date=date(2023, 1, 1),
Discharge_Date=date(2023, 2, 1),
Discharge_Destination="19",
Discharge_Method="1",
Spell_Core_HRG_SUS="XXX",
Der_Diagnosis_All="||E119 ,E780 ,J849 ||I801 ,I802 ,N179",
Der_Procedure_All="||E851,T124,X403||Y532,Z921",
Expand Down Expand Up @@ -332,6 +333,7 @@ def test_apcs(select_all_tpp):
"admission_date": date(2023, 1, 1),
"discharge_date": date(2023, 2, 1),
"discharge_destination": "19",
"discharge_method": "1",
"spell_core_hrg_sus": "XXX",
"all_diagnoses": "||E119 ,E780 ,J849 ||I801 ,I802 ,N179",
"all_procedures": "||E851,T124,X403||Y532,Z921",
Expand All @@ -347,6 +349,7 @@ def test_apcs(select_all_tpp):
"admission_date": date(2022, 6, 1),
"discharge_date": date(2022, 7, 1),
"discharge_destination": None,
"discharge_method": None,
"spell_core_hrg_sus": None,
"all_diagnoses": None,
"all_procedures": None,
Expand All @@ -362,6 +365,7 @@ def test_apcs(select_all_tpp):
"admission_date": date(2021, 4, 1),
"discharge_date": date(2021, 5, 1),
"discharge_destination": None,
"discharge_method": None,
"spell_core_hrg_sus": None,
"all_diagnoses": None,
"all_procedures": None,
Expand Down

0 comments on commit b101662

Please sign in to comment.