diff --git a/codelists/codelists.json b/codelists/codelists.json new file mode 100644 index 0000000..a616650 --- /dev/null +++ b/codelists/codelists.json @@ -0,0 +1,16 @@ +{ + "files": { + "opensafely-asthma-inhaler-salbutamol-medication.csv": { + "id": "opensafely/asthma-inhaler-salbutamol-medication/2020-04-15", + "url": "https://www.opencodelists.org/codelist/opensafely/asthma-inhaler-salbutamol-medication/2020-04-15/", + "downloaded_at": "2024-03-13 17:04:19.236457Z", + "sha": "1938865a29f7db8993532aba4d0cde68117c643b" + }, + "opensafely-ethnicity.csv": { + "id": "opensafely/ethnicity/2020-04-27", + "url": "https://www.opencodelists.org/codelist/opensafely/ethnicity/2020-04-27/", + "downloaded_at": "2023-10-02 10:13:20.621822Z", + "sha": "3d2f3998b71863a80b24d60f6f4282e14191ae13" + } + } +} \ No newline at end of file diff --git a/codelists/codelists.txt b/codelists/codelists.txt new file mode 100644 index 0000000..728bb8f --- /dev/null +++ b/codelists/codelists.txt @@ -0,0 +1,2 @@ +opensafely/asthma-inhaler-salbutamol-medication/2020-04-15 +opensafely/ethnicity/2020-04-27 diff --git a/codelists/opensafely-asthma-inhaler-salbutamol-medication.csv b/codelists/opensafely-asthma-inhaler-salbutamol-medication.csv new file mode 100644 index 0000000..c16f20e --- /dev/null +++ b/codelists/opensafely-asthma-inhaler-salbutamol-medication.csv @@ -0,0 +1,63 @@ +code,term,id,type,bnf_code +3408611000001107,Salbutamol 100micrograms/dose inhaler (A A H Pharmaceuticals Ltd),3408611000001107,amp,0301011R0AAAAAA +3410611000001106,Salbutamol 100micrograms/dose inhaler (Mylan),3410611000001106,amp,0301011R0AAAAAA +3412611000001107,Salbutamol 100micrograms/dose inhaler (Kent Pharmaceuticals Ltd),3412611000001107,amp,0301011R0AAAAAA +3415711000001107,Salbutamol 100micrograms/dose inhaler (Sandoz Ltd),3415711000001107,amp,0301011R0AAAAAA +3417111000001102,Salbutamol 100micrograms/dose inhaler (Alliance Healthcare (Distribution) Ltd),3417111000001102,amp,0301011R0AAAAAA +10432311000001108,Salbutamol 100micrograms/dose inhaler (Arrow Generics Ltd),10432311000001108,amp,0301011R0AAAAAA +7511000001105,Salbutamol 100micrograms/dose inhaler CFC free (Actavis UK Ltd),7511000001105,amp,0301011R0AAAPAP +45111000001100,Salbutamol 100micrograms/dose inhaler CFC free (Mylan),45111000001100,amp,0301011R0AAAPAP +757611000001104,Salbutamol 100micrograms/dose inhaler CFC free (Teva UK Ltd),757611000001104,amp,0301011R0AAAPAP +18041311000001106,Salbutamol 100micrograms/dose inhaler CFC free (Sandoz Ltd),18041311000001106,amp,0301011R0AAAPAP +840111000001107,Salbulin 100micrograms/dose inhaler (3M Health Care Ltd),840111000001107,amp,0301011R0BDAEAP +3382711000001107,Ventolin 200micrograms/dose Accuhaler (GlaxoSmithKline UK Ltd),3382711000001107,amp,0301011R0BEAHAQ +222311000001102,Ventolin 100micrograms/dose Evohaler (GlaxoSmithKline UK Ltd),222311000001102,amp,0301011R0BEAIAP +3214211000001100,Ventolin 200microgram Rotacaps (GlaxoSmithKline UK Ltd),3214211000001100,amp,0301011R0BEAPAV +3218011000001101,Ventolin 400microgram Rotacaps (GlaxoSmithKline UK Ltd),3218011000001101,amp,0301011R0BEAQAW +106511000001103,Salamol 100micrograms/dose inhaler CFC free (Teva UK Ltd),106511000001103,amp,0301011R0BIAFAP +3215311000001107,Salamol 100micrograms/dose Easi-Breathe inhaler (Teva UK Ltd),3215311000001107,amp,0301011R0BIAGBU +20434411000001107,Salamol 100micrograms/dose inhaler CFC free (Arrow Generics Ltd),20434411000001107,amp,0301011R0BIAHAP +3186011000001104,Asmasal 95micrograms/dose Clickhaler (Focus Pharmaceuticals Ltd),3186011000001104,amp,0301011R0BJABAF +3293111000001105,Aerolin 100micrograms/dose Autohaler (3M Health Care Ltd),3293111000001105,amp,0301011R0BKADAD +3080411000001101,Ventodisks 200microgram with Diskhaler (GlaxoSmithKline UK Ltd),3080411000001101,amp,0301011R0BLAAAI +3086111000001109,Ventodisks 200microgram (GlaxoSmithKline UK Ltd),3086111000001109,amp,0301011R0BLABAK +3083011000001100,Ventodisks 400microgram with Diskhaler (GlaxoSmithKline UK Ltd),3083011000001100,amp,0301011R0BLACAJ +3089011000001102,Ventodisks 400microgram (GlaxoSmithKline UK Ltd),3089011000001102,amp,0301011R0BLADAL +597011000001101,Airomir 100micrograms/dose inhaler (Teva UK Ltd),597011000001101,amp,0301011R0BMAAAP +3214311000001108,Airomir 100micrograms/dose Autohaler (Teva UK Ltd),3214311000001108,amp,0301011R0BMABBU +3214611000001103,Salbutamol 200 Cyclocaps (Teva UK Ltd),3214611000001103,amp,0301011R0BPACAV +3217611000001109,Salbutamol 400 Cyclocaps (Teva UK Ltd),3217611000001109,amp,0301011R0BPADAW +3384111000001103,Pulvinal Salbutamol 200micrograms/dose dry powder inhaler (Chiesi Ltd),3384111000001103,amp,0301011R0BTAABX +9205211000001104,Easyhaler Salbutamol sulfate 100micrograms/dose dry powder inhaler (Orion Pharma (UK) Ltd),9205211000001104,amp,0301011R0BWAABZ +9204911000001109,Easyhaler Salbutamol sulfate 200micrograms/dose dry powder inhaler (Orion Pharma (UK) Ltd),9204911000001109,amp,0301011R0BWABCA +13533511000001104,Salbulin Novolizer 100micrograms/dose inhalation powder (Mylan),13533511000001104,amp,0301011R0BXAACB +13533711000001109,Salbulin Novolizer 100micrograms/dose inhalation powder refill (Mylan),13533711000001109,amp,0301011R0BXABCC +18148111000001107,Asmavent 100micrograms/dose inhaler CFC free (Kent Pharmaceuticals Ltd),18148111000001107,amp,0301011R0BYAAAP +22503111000001109,AirSalb 100micrograms/dose inhaler CFC free (Sandoz Ltd),22503111000001109,amp,0301011R0BZAAAP +35936511000001108,Salbutamol 100micrograms/dose inhaler,35936511000001108,vmp,0301011R0AAAAAA +35936411000001109,Salbutamol 100micrograms/dose breath actuated inhaler,35936411000001109,vmp,0301011R0AAADAD +35937211000001107,Salbutamol 95micrograms/dose dry powder inhaler,35937211000001107,vmp,0301011R0AAAFAF +35936711000001103,Salbutamol 200microgram inhalation powder blisters with device,35936711000001103,vmp,0301011R0AAAIAI +35936911000001101,Salbutamol 400microgram inhalation powder blisters with device,35936911000001101,vmp,0301011R0AAAJAJ +35936611000001107,Salbutamol 200microgram inhalation powder blisters,35936611000001107,vmp,0301011R0AAAKAK +35936811000001106,Salbutamol 400microgram inhalation powder blisters,35936811000001106,vmp,0301011R0AAALAL +320139002,Salbutamol 100micrograms/dose inhaler CFC free,320139002,vmp,0301011R0AAAPAP +320141001,Salbutamol 200micrograms/dose dry powder inhaler,320141001,vmp,0301011R0AAAQAQ +320178003,Salbutamol 200microgram inhalation powder capsules,320178003,vmp,0301011R0AAAVAV +320179006,Salbutamol 400microgram inhalation powder capsules,320179006,vmp,0301011R0AAAWAW +320151000,Salbutamol 100micrograms/dose breath actuated inhaler CFC free,320151000,vmp,0301011R0AABUBU +9207411000001106,Salbutamol 100micrograms/dose dry powder inhaler,9207411000001106,vmp,0301011R0AABZBZ +13566211000001103,Salbutamol 100micrograms/dose dry powder inhalation cartridge with device,13566211000001103,vmp,0301011R0AACBCB +13566111000001109,Salbutamol 100micrograms/dose dry powder inhalation cartridge,13566111000001109,vmp,0301011R0AACCCC +320132006,VMP previous to 35936711000001103,320132006,vmp,0301011R0AAAIAI +320133001,VMP previous to 35936911000001101,320133001,vmp,0301011R0AAAJAJ +320134007,VMP previous to 35936611000001107,320134007,vmp,0301011R0AAAKAK +320135008,VMP previous to 35936811000001106,320135008,vmp,0301011R0AAALAL +320136009,VMP previous to 35936411000001109,320136009,vmp,0301011R0AAADAD +320148007,VMP previous to 35937211000001107,320148007,vmp,0301011R0AAAFAF +320176004,VMP previous to 35936511000001108,320176004,vmp,0301011R0AAAAAA +39112711000001103,VMP subsequent to 320151000,39112711000001103,vmp,0301011R0AABUBU +39113311000001107,VMP subsequent to 320141001,39113311000001107,vmp,0301011R0AAAQAQ +39113611000001102,VMP subsequent to 320139002,39113611000001102,vmp,0301011R0AAAPAP +39709711000001100,VMP subsequent to 320178003,39709711000001100,vmp,0301011R0AAAVAV +39709811000001108,VMP subsequent to 320179006,39709811000001108,vmp,0301011R0AAAWAW diff --git a/codelists/opensafely-ethnicity.csv b/codelists/opensafely-ethnicity.csv new file mode 100644 index 0000000..24287eb --- /dev/null +++ b/codelists/opensafely-ethnicity.csv @@ -0,0 +1,271 @@ +Description,Code,Grouping_16,Grouping_6 +Race: Caucasian,134B.,1,1 +Race - British,Y9930,1,1 +White - ethnic group,9S1..,1,1 +White British,XaFwD,1,1 +Other white British ethnic group,XaIui,1,1 +British or mixed British - ethnic category 2001 census,XaJQv,1,1 +White British - ethnic category 2001 census,XaQEa,1,1 +White:Eng/Welsh/Scot/NI/Brit - England and Wales 2011 census,XactH,1,1 +Irish (NMO),9SA9.,2,1 +White Irish,XaFwE,2,1 +Irish - ethnic category 2001 census,XaJQw,2,1 +Mixed Irish and other White - ethnic category 2001 census,XaJSN,2,1 +White Irish - ethnic category 2001 census,XaQEb,2,1 +White: Irish - England and Wales ethnic category 2011 census,XactI,2,1 +White: Irish - Scotland ethnic category 2011 census,Xacuu,2,1 +Race - Mediterranean,Y9932,3,1 +Greek &/or Greek Cypriot (NMO),9SAA.,3,1 +Turkish &/or Turkish Cypriot (NMO),9SAB.,3,1 +Other European (NMO),9SAC.,3,1 +New Zealand European,9T11.,3,1 +Greek/Greek Cypriot (NMO),XE2Nz,3,1 +Turkish/Turkish Cypriot (NMO),XE2O0,3,1 +Greek (NMO),XM1SF,3,1 +Greek Cypriot (NMO),XM1SG,3,1 +Turkish (NMO),XM1SH,3,1 +Turkish Cypriot (NMO),XM1SI,3,1 +Gypsies,XS7AU,3,1 +Other white ethnic group,XaFwF,3,1 +Irish traveller,XaFx2,3,1 +White Scottish,XaIuh,3,1 +Other White background - ethnic category 2001 census,XaJQx,3,1 +English - ethnic category 2001 census,XaJRC,3,1 +Scottish - ethnic category 2001 census,XaJRD,3,1 +Welsh - ethnic category 2001 census,XaJRE,3,1 +Northern Irish - ethnic category 2001 census,XaJRF,3,1 +Cornish - ethnic category 2001 census,XaJRG,3,1 +Cypriot (part not stated) - ethnic category 2001 census,XaJRg,3,1 +Ulster Scots - ethnic category 2001 census,XaJRh,3,1 +Greek - ethnic category 2001 census,XaJRi,3,1 +Greek Cypriot - ethnic category 2001 census,XaJRj,3,1 +Turkish - ethnic category 2001 census,XaJRk,3,1 +Turkish Cypriot - ethnic category 2001 census,XaJRl,3,1 +Italian - ethnic category 2001 census,XaJRm,3,1 +Irish Traveller - ethnic category 2001 census,XaJSB,3,1 +Traveller - ethnic category 2001 census,XaJSC,3,1 +Gypsy/Romany - ethnic category 2001 census,XaJSD,3,1 +Polish - ethnic category 2001 census,XaJSE,3,1 +Baltic Estonian/Latvian/Lithuanian - ethn categ 2001 census,XaJSF,3,1 +Commonwealth (Russian) Indep States - ethn categ 2001 census,XaJSG,3,1 +Kosovan - ethnic category 2001 census,XaJSH,3,1 +Albanian - ethnic category 2001 census,XaJSI,3,1 +Bosnian - ethnic category 2001 census,XaJSJ,3,1 +Croatian - ethnic category 2001 census,XaJSK,3,1 +Serbian - ethnic category 2001 census,XaJSL,3,1 +Other republics former Yugoslavia - ethnic categ 2001 census,XaJSM,3,1 +Other mixed White - ethnic category 2001 census,XaJSO,3,1 +Oth White European/European unsp/Mixed European 2001 census,XaJSP,3,1 +Other White or White unspecified ethnic category 2001 census,XaJSQ,3,1 +Romanian,XaR4o,3,1 +Bulgarian,XaR4p,3,1 +Czech,XaR61,3,1 +Slovak,XaVw5,3,1 +Portuguese,XaW8w,3,1 +White: Gypsy/Irish Traveller - Eng+Wales eth cat 2011 census,XactJ,3,1 +White: other White backgrd- Eng+Wales ethnic cat 2011 census,XactK,3,1 +White - Northern Ireland ethnic category 2011 census,XacuQ,3,1 +Irish Traveller - Northern Ireland ethnic cat 2011 census,XacuR,3,1 +White: Scottish - Scotland ethnic category 2011 census,Xacus,3,1 +White: other British - Scotland ethnic category 2011 census,Xacut,3,1 +White: Gypsy/Irish Traveller - Scotland ethnic cat 2011 cens,Xacuv,3,1 +White: Polish - Scotland ethnic category 2011 census,Xacux,3,1 +White: other White ethnic grp- Scotland ethnic cat 2011 cens,Xacuy,3,1 +Slovak Roma,XaedN,3,1 +Czech Roma,XaedQ,3,1 +Hungarian Roma,XaedS,3,1 +Polish Roma,XaedT,3,1 +Romanian Roma,XaedU,3,1 +Roma ethnic group,XaedV,3,1 +Bulgarian Roma,XaedW,3,1 +Traveller,Y1527,3,1 +Black Caribbean and White,XaIB5,4,2 +White and Black Caribbean - ethnic category 2001 census,XaJQy,4,2 +Mixed: White+Black Caribbean - Eng+Wales eth cat 2011 census,XactL,4,2 +Mixed: White and Black Caribbean - NI ethnic cat 2011 census,XacuS,4,2 +Race: Afro-caucasian,134L.,5,2 +Black African and White,XaIB6,5,2 +White and Black African - ethnic category 2001 census,XaJQz,5,2 +Mixed: White+Black African - Eng+Wales eth cat 2011 census,Xactd,5,2 +Mixed: White and Black African - NI ethnic cat 2011 census,XacuT,5,2 +"Other ethnic, Asian/White orig",9SB2.,6,2 +White and Asian - ethnic category 2001 census,XaJR0,6,2 +Mixed: White+Asian - Eng+Wales ethnic category 2011 census,Xacte,6,2 +Mixed: White and Asian - NI ethnic category 2011 census,XacuU,6,2 +Race: Mixed,134J.,7,2 +"Black - other, mixed",9S5..,7,2 +"Black - other, mixed",9S5..,7,2 +Other Black - Black/White orig,9S51.,7,2 +Other Black - Black/White orig,9S51.,7,2 +Other Black - Black/Asian orig,9S52.,7,2 +Other Black - Black/Asian orig,9S52.,7,2 +"Other ethnic, mixed origin",9SB..,7,2 +"Other ethnic, Black/White orig",9SB1.,7,2 +"Other ethnic, mixed white orig",9SB3.,7,2 +"Other ethnic, other mixed orig",9SB4.,7,2 +Mixed ethnic census group,XaFwG,7,2 +Other Mixed background - ethnic category 2001 census,XaJR1,7,2 +Black and Asian - ethnic category 2001 census,XaJRH,7,2 +Black and Chinese - ethnic category 2001 census,XaJRI,7,2 +Black and White - ethnic category 2001 census,XaJRJ,7,2 +Chinese and White - ethnic category 2001 census,XaJRK,7,2 +Asian and Chinese - ethnic category 2001 census,XaJRL,7,2 +Other Mixed or Mixed unspecified ethnic category 2001 census,XaJRM,7,2 +Mixed Asian - ethnic category 2001 census,XaJRN,7,2 +Mixed Black - ethnic category 2001 census,XaJRY,7,2 +Mixed: other Mixed/multiple backgrd - Eng+Wales 2011 census,Xactf,7,2 +Mixed: other Mixed/multiple ethnic backgrd - NI 2011 census,Xacua,7,2 +Mixed/multiple ethnic grps: any- Scot ethnic cat 2011 census,Xacuz,7,2 +Race - Indian,Y9931,8,3 +Indian,9S6..,8,3 +Indian sub-continent (NMO),9SA7.,8,3 +Indian or British Indian - ethnic category 2001 census,XaJR2,8,3 +Asian/Asian Brit: Indian - Eng+Wales ethnic cat 2011 census,Xactg,8,3 +Asian or Asian British: Indian - NI ethnic cat 2011 census,Xacuc,8,3 +"Asian: Indian, Indian Scot/Indian Brit- Scotland 2011 census",Xacv2,8,3 +Race: Pakistani,134M.,9,3 +Pakistani,9S7..,9,3 +Pakistani or British Pakistani - ethnic category 2001 census,XaJR3,9,3 +Asian/Asian British:Pakistani- Eng+Wales eth cat 2011 census,Xacth,9,3 +Asian/Asian British: Pakistani - NI ethnic cat 2011 census,Xacui,9,3 +Asian: Pakistani/Pakistani Scot/Pakistani Brit- Scot 2011,Xacv0,9,3 +Race: Bangladeshi,134I.,10,3 +Bangladeshi,9S8..,10,3 +Bangladeshi or British Bangladeshi - ethn categ 2001 census,XaJR4,10,3 +Asian/Asian Brit: Bangladeshi- Eng+Wales eth cat 2011 census,Xacti,10,3 +Asian/Asian British: Bangladeshi - NI ethnic cat 2011 census,Xacuj,10,3 +"Bangladeshi, Bangladeshi Scot or Bangladeshi Brit- Scot 2011",Xacv5,10,3 +E Afric Asian &/or Indo-Carib (NMO),9SA6.,11,3 +Other Asian (NMO),9SA8.,11,3 +South East Asian,9T1B.,11,3 +Other Asian,9T1E.,11,3 +E Afric Asian/Indo-Carib (NMO),XE2Ny,11,3 +East African Asian (NMO),XM1SD,11,3 +Indo-Caribbean (NMO),XM1SE,11,3 +Asian - ethnic group,XaFwz,11,3 +Other Asian ethnic group,XaFx0,11,3 +Other Asian background - ethnic category 2001 census,XaJR5,11,3 +Punjabi - ethnic category 2001 census,XaJRO,11,3 +Kashmiri - ethnic category 2001 census,XaJRP,11,3 +East African Asian - ethnic category 2001 census,XaJRQ,11,3 +Sri Lankan - ethnic category 2001 census,XaJRR,11,3 +Tamil - ethnic category 2001 census,XaJRS,11,3 +Sinhalese - ethnic category 2001 census,XaJRT,11,3 +British Asian - ethnic category 2001 census,XaJRU,11,3 +Caribbean Asian - ethnic category 2001 census,XaJRV,11,3 +Other Asian or Asian unspecified ethnic category 2001 census,XaJRW,11,3 +Nepali,XaW95,11,3 +Asian/Asian Brit: other Asian- Eng+Wales eth cat 2011 census,Xactk,11,3 +Asian/Asian British: other Asian - NI ethnic cat 2011 census,Xacul,11,3 +Asian: other Asian group - Scotland ethnic cat 2011 census,XacvG,11,3 +Race: Afro-Caribbean,134H.,12,4 +Race: West indian,134K.,12,4 +Black Caribbean,9S2..,12,4 +Black Caribbean &/or W.I. &/or Guyana,9S42.,12,4 +Caribbean I. &/or W.I. &/or Guyana (NMO),9SA3.,12,4 +Black Caribbean/W.I./Guyana,XE2Nt,12,4 +Caribbean I./W.I./Guyana (NMO),XE2Nw,12,4 +Caribbean Island (NMO),XM1S8,12,4 +West Indian (NMO),XM1S9,12,4 +Black West Indian,XaBz7,12,4 +Caribbean - ethnic category 2001 census,XaJR6,12,4 +Carib/Black: Caribbean/Carib Scot/Carib Brit- Scotland 2011,XacvJ,12,4 +Black African,9S3..,13,4 +Other African countries (NMO),9SA5.,13,4 +Black North African,XM1S3,13,4 +African - ethnic category 2001 census,XaJR7,13,4 +North African - ethnic category 2001 census,XaJST,13,4 +African: African/African Scot/African Brit - Scotland 2011,XacvH,13,4 +African: any other African - Scotland ethnic cat 2011 census,XacvI,13,4 +"Black, other, non-mixed origin",9S4..,14,4 +Black British,9S41.,14,4 +Black N African &/or Arab &/or Iranian,9S43.,14,4 +Black - other African country,9S44.,14,4 +Black E Afric Asia &/or Indo-Caribb,9S45.,14,4 +Black Indian sub-continent,9S46.,14,4 +Black - other Asian,9S47.,14,4 +Black Black - other,9S48.,14,4 +Black N African/Arab/Iranian,XE2Nu,14,4 +Black East African Asian/Indo-Caribbean,XE2Nv,14,4 +Black Arab,XM1S4,14,4 +Black Iranian,XM1S5,14,4 +Black East African Asian,XM1S6,14,4 +Black Indo-Caribbean,XM1S7,14,4 +Guyana (NMO),XM1SA,14,4 +Black Guyana,XaBz8,14,4 +Black - ethnic group,XaFwH,14,4 +Other black ethnic group,XaFwy,14,4 +Other Black background - ethnic category 2001 census,XaJR8,14,4 +Somali - ethnic category 2001 census,XaJRX,14,4 +Nigerian - ethnic category 2001 census,XaJRZ,14,4 +Black British - ethnic category 2001 census,XaJRa,14,4 +Other Black or Black unspecified ethnic category 2001 census,XaJRb,14,4 +Black/African/Carib/Black Brit: African- Eng+Wales 2011 cens,Xactl,14,4 +Black/African/Caribbn/Black Brit: Caribbean - Eng+Wales 2011,Xactm,14,4 +Black/Afr/Carib/Black Brit: other Black- Eng+Wales 2011 cens,Xactn,14,4 +Black/Afri/Carib/Black Brit: African- NI eth cat 2011 census,Xacum,14,4 +Black/Afri/Carib/Black Brit: Caribbean- NI eth cat 2011 cens,Xacun,14,4 +Black/Afri/Carib/Black Brit: other - NI eth cat 2011 census,Xacuo,14,4 +Carib/Black: Black/Black Scot/Black Brit- Scotland 2011 cens,XacvZ,14,4 +Carib/Black: any other Black/Caribbean grp - Scotland 2011,Xacva,14,4 +Chinese,9T1C.,15,5 +Chinese,9T1C.,15,5 +Chinese - ethnic category 2001 census,XaJR9,15,5 +Asian/Asian Brit: Chinese - Eng+Wales ethnic cat 2011 census,Xactj,15,5 +Asian/Asian British: Chinese - NI ethnic cat 2011 census,Xacuk,15,5 +Asian: Chinese - Scotland ethnic category 2011 census,XacvF,15,5 +Race: Arab,134C.,16,5 +Race: Chinese,134D.,16,5 +Race: Japanese,134E.,16,5 +Race: Korean,134F.,16,5 +Race: Oriental,134G.,16,5 +Race: Other,X76Gp,16,5 +Other ethnic non-mixed (NMO),9SA..,16,5 +Brit. ethnic minor. spec.(NMO),9SA1.,16,5 +Brit. ethnic minor. unsp (NMO),9SA2.,16,5 +N African Arab &/or Iranian (NMO),9SA4.,16,5 +Other ethnic NEC (NMO),9SAD.,16,5 +New Zealand ethnic groups,9T1..,16,5 +Other European in New Zealand,9T12.,16,5 +New Zealand Maori,9T13.,16,5 +Samoan,9T14.,16,5 +Cook Island Maori,9T15.,16,5 +Tongan,9T16.,16,5 +Niuean,9T17.,16,5 +Tokelauan,9T18.,16,5 +Fijian,9T19.,16,5 +Other Pacific ethnic group,9T1A.,16,5 +Other New Zealand ethnic group,9T1Y.,16,5 +New Zealand ethnic group NOS,9T1Z.,16,5 +N African Arab/Iranian (NMO),XE2Nx,16,5 +North African Arab (NMO),XM1SB,16,5 +Iranian (NMO),XM1SC,16,5 +Vietnamese,XaE4A,16,5 +Other ethnic group,XaFx1,16,5 +Other - ethnic category 2001 census,XaJRA,16,5 +Vietnamese - ethnic category 2001 census,XaJRc,16,5 +Japanese - ethnic category 2001 census,XaJRd,16,5 +Filipino - ethnic category 2001 census,XaJRe,16,5 +Malaysian - ethnic category 2001 census,XaJRf,16,5 +Jewish - ethnic category 2001 census,XaJSR,16,5 +Arab - ethnic category 2001 census,XaJSS,16,5 +"Mid East (excl Israeli, Iranian & Arab) - eth cat 2001 cens",XaJSU,16,5 +Israeli - ethnic category 2001 census,XaJSV,16,5 +Iranian - ethnic category 2001 census,XaJSW,16,5 +Kurdish - ethnic category 2001 census,XaJSX,16,5 +Moroccan - ethnic category 2001 census,XaJSY,16,5 +Latin American - ethnic category 2001 census,XaJSZ,16,5 +South and Central American - ethnic category 2001 census,XaJSa,16,5 +Mauritian/Seychellois/Maldivian/St Helena eth cat 2001census,XaJSb,16,5 +Buddhist - ethnic category 2001 census,XaJSc,16,5 +Hindu - ethnic category 2001 census,XaJSd,16,5 +Muslim - ethnic category 2001 census,XaJSe,16,5 +Sikh - ethnic category 2001 census,XaJSf,16,5 +Any other group - ethnic category 2001 census,XaJSg,16,5 +Yemeni,XaN9x,16,5 +Other ethnic group: Arab - Eng+Wales ethnic cat 2011 census,Xacto,16,5 +Other ethnic: any other grp - Eng+Wales eth cat 2011 census,Xactp,16,5 +Other ethnic group: Arab - NI ethnic category 2011 census,Xacup,16,5 +Other ethnic group: any other grp- NI ethnic cat 2011 census,Xacuq,16,5 +Other ethnic grp: Arab/Arab Scot/Arab British- Scotland 2011,Xacvb,16,5 +Other ethnic grp: any other ethnic grp- Scotland 2011 census,Xacvc,16,5 \ No newline at end of file diff --git a/dataset_definition.py b/dataset_definition.py index e69de29..1708a77 100644 --- a/dataset_definition.py +++ b/dataset_definition.py @@ -0,0 +1,83 @@ +from ehrql import case, codelist_from_csv, create_dataset, days, when +from ehrql.tables.beta.core import medications, patients +from ehrql.tables.beta.tpp import ( + addresses, + clinical_events, + hospital_admissions, + practice_registrations, +) + +index_date = "2023-10-01" + +dataset = create_dataset() + +dataset.configure_dummy_data(population_size=10) + +# codelists + +ethnicity_codelist = codelist_from_csv( + "codelists/opensafely-ethnicity.csv", + column="Code", + category_column="Grouping_6", +) + +asthma_inhaler_codelist = codelist_from_csv( + "codelists/opensafely-asthma-inhaler-salbutamol-medication.csv", + column="code", + category_column="term", +) + +# population variables + +was_female_or_male = patients.sex.is_in(["female", "male"]) + +was_adult = (patients.age_on(index_date) >= 18) & (patients.age_on(index_date) <= 110) + +was_alive = ( + patients.date_of_death.is_after(index_date) | patients.date_of_death.is_null() +) + +was_registered = practice_registrations.for_patient_on(index_date).exists_for_patient() + +dataset.define_population(was_female_or_male & was_adult & was_alive & was_registered) + +# demographic variables + +dataset.age = patients.age_on(index_date) + +dataset.sex = patients.sex + +dataset.ethnicity = ( + clinical_events.where(clinical_events.ctv3_code.is_in(ethnicity_codelist)) + .sort_by(clinical_events.date) + .last_for_patient() + .ctv3_code.to_category(ethnicity_codelist) +) + +imd_rounded = addresses.for_patient_on(index_date).imd_rounded +max_imd = 32844 + +dataset.imd_quintile = case( + when(imd_rounded < int(max_imd * 1 / 5)).then(1), + when(imd_rounded < int(max_imd * 2 / 5)).then(2), + when(imd_rounded < int(max_imd * 3 / 5)).then(3), + when(imd_rounded < int(max_imd * 4 / 5)).then(4), + when(imd_rounded <= max_imd).then(5), +) + +# exposure variable + +dataset.num_asthma_inhaler_medications = ( + medications.where(medications.dmd_code.is_in(asthma_inhaler_codelist)) + .where(medications.date.is_on_or_between(index_date - days(30), index_date)) + .count_for_patient() +) + +# outcome variable + +dataset.date_first_admitted = ( + hospital_admissions.where(hospital_admissions.admission_date.is_after(index_date)) + .sort_by(hospital_admissions.admission_date) + .first_for_patient() + .admission_date +) diff --git a/project.yaml b/project.yaml new file mode 100644 index 0000000..fcf13f0 --- /dev/null +++ b/project.yaml @@ -0,0 +1,11 @@ +version: "3.0" + +expectations: + population_size: 1000 + +actions: + generate_dataset: + run: ehrql:v0 generate-dataset --output dataset.csv.gz dataset_definition.py + outputs: + highly_sensitive: + dataset: dataset.csv.gz