Skip to content

Commit

Permalink
Merge pull request #976 from opensafely-core/steve/remove-ons-cis
Browse files Browse the repository at this point in the history
Remove ONS CIS data
  • Loading branch information
iaindillingham authored Jul 28, 2023
2 parents 5e56f16 + d0a7a1b commit 7f5e591
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 903 deletions.
278 changes: 0 additions & 278 deletions cohortextractor/ons_cis_utils.py

This file was deleted.

84 changes: 0 additions & 84 deletions cohortextractor/patients.py
Original file line number Diff line number Diff line change
Expand Up @@ -2842,90 +2842,6 @@ def with_an_isaric_record(
return "with_an_isaric_record", locals()


def with_an_ons_cis_record(
returning,
return_category_labels=True,
# Date filtering: column to filter
date_filter_column=None,
# Date filtering: date limits
on_or_before=None,
on_or_after=None,
between=None,
# Matching rule
find_first_match_in_period=None,
find_last_match_in_period=None,
include_date_of_match=False,
date_format=None,
return_expectations=None,
):
"""
Return whether patient has an ONS CIS record
Args:
returning: string value; options are:
* "binary_flag"
* "number_of_matches_in_period"
* the ONS CIS table column to return
return_category_labels: If the value of `returning` is a coded category, return the
the corresponding longform string labels
date_filter_column: the ONS CIS column to use with date limit args; options are:
* "covid_date"
* "covid_test_blood_neg_last_date"
* "covid_test_blood_pos_first_date"
* "covid_test_swab_neg_last_date"
* "covid_test_swab_pos_first_date"
* "received_ox_date"
* "result_mk_date"
* "samples_taken_date"
* "sympt_now_date"
* "travel_abroad_date"
* "visit_date"
`date_filter_column` is not required when returning "number_of_matches_in_period", with no
date limit arguments. It is required for all other `returning` options
on_or_before: date of interest as a string with the format `YYYY-MM-DD`. Filters results to measurements
on or before the given date (as defined by `date_filter_column`).
on_or_after: date of interest as a string with the format `YYYY-MM-DD`. Filters results to measurements
on or after the given date (as defined by `date_filter_column`).
between: two dates of interest as a list with each date as a string with the format `YYYY-MM-DD`.
Filters results to measurements between the two dates (as defined by `date_filter_column`)
provided (inclusive).
The two dates must be in chronological order.
find_first_match_in_period: as described elsewhere
find_last_match_in_period: as described elsewhere
include_date_of_match: a boolean indicating if an extra column containing the date (from `date_filter_column`)
of the match should be returned.
date_format: a string detailing the format of dates to be returned.
It can be "YYYY-MM-DD", "YYYY-MM" or "YYYY" and wherever possible the least disclosive data should be
returned. i.e returning only year is less disclosive than a date with month and year.
return_expectations: as described elsewhere.
Example:
Return cleaned employment status (as longform category labels) for patients with a positive covid blood test
after 01 Jan 2022, returning also the date of the positive covid blood test:
employment_status = patients.with_an_ons_cis_record(
returning="work_status_clean",
return_category_labels=True,
date_filter_column="covid_test_blood_pos_first_date",
on_or_after="2022-01-01",
find_first_match_in_period=True,
include_date_of_match=True,
date_format="YYYY-MM-DD",
return_expectations={
"rate": "universal",
"category": {
"ratios": {"Not working": 0.2, "Working": 0.6, "Student": 0.2},
},
},
)
"""
return "with_an_ons_cis_record", locals()


def with_record_in_ukrr(
# picks dataset held by UK Renal Registry (UKRR)
from_dataset=None,
Expand Down
9 changes: 0 additions & 9 deletions cohortextractor/process_covariate_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import datetime
import re

from .ons_cis_utils import ONS_CIS_CATEGORY_COLUMNS, ONS_CIS_COLUMN_MAPPINGS

# ISARIC data has a lot of columns that are all varchar in the db.
ISARIC_COLUMN_MAPPINGS = {
"abdopain_ceoccur_v2": "str",
Expand Down Expand Up @@ -813,13 +811,6 @@ def type_of_with_covid_therapeutics(self, returning, **kwargs):
def type_of_with_an_isaric_record(self, returning, **kwargs):
return ISARIC_COLUMN_MAPPINGS[returning]

def type_of_with_an_ons_cis_record(self, returning, **kwargs):
if returning in ONS_CIS_CATEGORY_COLUMNS:
return "str"
elif returning in ONS_CIS_COLUMN_MAPPINGS:
return ONS_CIS_COLUMN_MAPPINGS[returning]
return self._type_from_return_value(returning)

def type_of_with_record_in_ukrr(self, returning, **kwargs):
return self._type_from_return_value(returning)

Expand Down
Loading

0 comments on commit 7f5e591

Please sign in to comment.