Code Monkey home page Code Monkey logo

aecopd's Introduction

How to: find acute exacerbation of chronic obstructive pulmonary disease (AECOPD) events in UK primary care electronic healthcare records (EHRs)

AECOPD algorithm (Rothnie et al., 2016)

The Algorithms with PPV > 75% shown below represent the best AECOPD detection method in UK primary care EHRs.

In summary, an AECOPD can be in found in primary care EHRs by excluding any events on a COPD annual review day and searching for any of the following events:

Any of these events closer together than 14 days are considered part of the same exacerbation event.

*Prescription duration is poorly recorded in CPRD Aurum, therefore any day where a patient receives a prescription for both an antibiotic and oral corticosteroid is counted as an exacerbation event.

Example Stata code

The do file containing this code as well as the annual_review, AECOPD_symptoms, LRTI, AECOPD, and antibiotics_ocs codelists can be found in the parent directory of this repository.

1. Set working directory. In this example I have assumed that all data files and codelists are in the same working directory.

cd "<path to codelists and data files>"

2. Open clinical events file, e.g. "Observation" file in CPRD Aurum.

use Observation, clear

3. Merge events file with SNOMED CT codelists to get clinical events of interest.

merge 1:1 snomedctdescriptionid using annual_review.csv, nogenerate keep(match master)
merge 1:1 snomedctdescriptionid using AECOPD_symptoms.csv, nogenerate keep(match master)
merge 1:1 snomedctdescriptionid using LRTI.csv, nogenerate keep(match master)
merge 1:1 snomedctdescriptionid using AECOPD.csv, nogenerate keep(match master)

4. Just keep clinical events of interest.

drop if copd_annualreview == . & breathlessness == . & cough == . & sputum == . & lrti == . & aecopd == .

5. Save temporary file containing clinical events of interest.

tempfile review_symptoms_LRTI_AECOPD
save `review_symptoms_LRTI_AECOPD'

6. Open prescription events file, e.g. "DrugIssue" file in CPRD Aurum.

use DrugIssue, clear

7. Merge prescription file with DM+D codelists to get prescription events of interest.

merge 1:1 snomedctdescriptionid using `antibiotics_ocs', nogenerate keep(match master)

8. Just keep prescription events of interest.

drop if antibiotic == . & oral_corticosteroid == .

9. Rename date of prescription variable to have the same name as date of clinical event variable so that date of prescription or event are represented with just one variable.

rename issuedate obsdate

10. Append clinical event data to prescription event date to obtain all events of interest in one file.

append using `review_symptoms_LRTI_AECOPD'

11. Sort new combined clinical and prescription event file by date fore each patient so that older events are listed first.

gsort patid obsdate

12. Collapse data by patient and date to get all events on the same day.

collapse (max) annual_review antibiotic oral_corticosteroid breathlessness cough sputum lrti aecopd, by(patid obsdate)

13. Remove events on an annual review day.

drop if annual_review == 1
drop annual_review

14. Calculate total number of symptoms on a specific day.

egen symptoms = rowtotal(breathlessness cough sputum)
order symptoms, after(sputum)

15. Only keep days where both antibiotics and oral corticosteroids were prescribed, days where a patient had 2 or more symptoms and an antibiotic or oral corticosteroid prescribed, days where a patient received an AECOPD code, or days where a patient received a LRTI code.

keep if (abx == 1 & ocs == 1) ///
	  | (symptoms >= 2 & (abx == 1 | ocs == 1)) ///
	  | aecopd == 1 ///
	  | lrti == 1

16. Count any day with the events above as an exacerbation, excluding events closer together than 14 days.

by patid: gen exacerbation = 1 if _n == 1 | obsdate[_n-1] < obsdate-14

17. You now have a list of exacerbations for each patient. If you run the collapse command you can generate the total number of exacerbations for each patient over the given time peroid.

collapse (sum) exacerbations=exacerbation, by(patid)

aecopd's People

Contributors

pstone22 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.