Skip to content

Commit e3fe32e

Browse files
authored
Merge pull request #511 from The-Strategy-Unit/486_add-age-group-to-full-results
add age_group to IP full results converted to other activity types
2 parents 7a4608d + 5f48e5a commit e3fe32e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/nhp/model/inpatients.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def _save_results_get_op_converted(self, model_results: pd.DataFrame) -> pd.Data
307307
ix = model_results["classpat"] == "-1"
308308
return (
309309
model_results[ix]
310-
.groupby(["age", "sex", "tretspef", "tretspef_grouped", "sitetret"])
310+
.groupby(["age", "age_group", "sex", "tretspef", "tretspef_grouped", "sitetret"])
311311
.size()
312312
.to_frame("attendances")
313313
.assign(tele_attendances=0)
@@ -318,7 +318,7 @@ def _save_results_get_sdec_converted(self, model_results: pd.DataFrame) -> pd.Da
318318
ix = model_results["classpat"] == "-3"
319319
return (
320320
model_results[ix]
321-
.groupby(["age", "sex", "sitetret"])
321+
.groupby(["age", "age_group", "sex", "sitetret"])
322322
.size()
323323
.to_frame("arrivals")
324324
.assign(

tests/unit/nhp/model/test_inpatients.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ def test_save_results_get_op_converted(mock_model):
589589
"classpat": ["-1", "1"] * 3,
590590
"speldur": [0, 1] * 3,
591591
"age": [1, 2] * 3,
592+
"age_group": ["a", "b"] * 3,
592593
"sex": [1, 2] * 3,
593594
"tretspef": ["a", "b"] * 3,
594595
"tretspef_grouped": ["a", "b"] * 3,
@@ -598,6 +599,7 @@ def test_save_results_get_op_converted(mock_model):
598599
expected = pd.DataFrame(
599600
{
600601
"age": [1, 1],
602+
"age_group": ["a", "a"],
601603
"sex": [1, 1],
602604
"tretspef": ["a", "a"],
603605
"tretspef_grouped": ["a", "a"],
@@ -624,6 +626,7 @@ def test_save_results_get_sdec_converted(mock_model):
624626
"classpat": ["-3", "1"] * 3,
625627
"speldur": [0, 1] * 3,
626628
"age": [1, 2] * 3,
629+
"age_group": ["a", "b"] * 3,
627630
"sex": [1, 2] * 3,
628631
"tretspef": ["a", "b"] * 3,
629632
"tretspef_grouped": ["a", "b"] * 3,
@@ -633,6 +636,7 @@ def test_save_results_get_sdec_converted(mock_model):
633636
expected = pd.DataFrame(
634637
{
635638
"age": [1, 1],
639+
"age_group": ["a", "a"],
636640
"sex": [1, 1],
637641
"sitetret": ["1", "2"],
638642
"arrivals": [2, 1],

0 commit comments

Comments
 (0)