Hi All,
I am working on an electronic health record database where I have selected individuals using some specific drugs. I want to use the last medication received to categorize each patient into a particular drug class. However, some received multiple drugs on the same date and I would like to completely remove them from my data. See the example table below;
PersonID | Visit ID | Medication description | Start date | Drug class A | Drug class B | Drug class C |
2 | 389965 | Drug class A | 28th Nov 2015 | 1 | 0 | 0 |
2 | 389965 | Drug class A | 1st Feb 2016 | 1 | 0 | 0 |
2 | 614578 | Drug class A | 19thJune 2019 | 1 | 0 | 0 |
2 | 1456893 | Drug class A | 10th Oct 2020 | 1 | 0 | 0 |
4 | 604822 | Drug class B | 13 May 2019 | 0 | 1 | 0 |
4 | 965534 | Drug class B | 19 Aug 2019 | 0 | 1 | 0 |
4 | 453398 | Drug class B | 01 April 2020 | 0 | 1 | 0 |
4 | 212234 | Drug class B | 13 May 2020 | 0 | 1 | 0 |
4 | 212234 | Drug class A | 13 May 2020 | 1 | 0 | 0 |
For patient 2, based on their last date they are certainly on drug class A, but for patient 4 based on their last date, he was on a multiple drug combination. How do I delete patient 4 and all similar patients from my database using just the data from their more recent records?
Thank you all.