Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Coding for multiple medicines

    I was wondering if anyone had some ideas on how I can approach a problem with my dataset. I have a variable that identifies when medicines were dispensed both the first and last time for the unique medicine and for each drug class. I want to be able to classify each unique medicine as to whether it was discontinued or whether it was switched to another medicine in the same class. I've defined switching and discontinued as:
    SWITCHING

    Where a medicine will be identified as an initial supply, we will confirm if another medicine at the same ATC4th level (e.g N02AB) has previously been supplied. Where another medicine in the same class has previously been supplied, we will confirm if the final supply date for the original medicine preceded the first supply date for the newly initiated medicine. These medicines were classified as “switched” rather than newly initiated medicines. However, where the original medicine was dispensed at least once after the newly initiated medicine was dispensed, both medicines were considered as concurrent supply rather than switched.
    DISCONTINUATION

    Medicines were categorised as discontinued if it were the last known supply, and it had not been switched to another medicine within the same class. It was considered as discontinued once a period of 45 days had passed since the last supply date.

    RESTARTED
    Medicines were categorised as restarted if where they were discontinued, there was at least one calendar year with no supply and then it was supplied again.

    I have tried a number of different options to create the three variables to identify medicines that are switched, discontinued and restarted. Time series options are not seeming to work as there seem to be some issues with uniquely identifying data, although I cannot identify where the duplicates are. Does anyone have any suggestions?



    The dataset
    I have multiple people on who have had medicines dispensed in at least once in at least one year. The data are long by year so there is an observation per participant (identified by pat_id) per unique medicine (identified by ATCcode).

    A person who used a medicine regularly and was compliant would have the medicine dispensed once each month. Dispensed_q1-dispensed_q4 are variables the identify if the medicine was dispensed at least once in the first quarter (January, February or March), second quarter (April, May, June), third quarter (July, August, September) or fourth quarter (October, November, December).

    The ATC code is a WHO categorisation that identifies medicines. There are five levels in the ATC code from level 1 that identifies body system (skin, antiinfectives) down to level 5 that identifies the unique individual medicine. I have the ATCcode that represents the unique medicine. There is also an atc4th variable that identifies the medicine at the ATC level one, which is the drug class. This is important as sometimes people stop a medicine to use another medicine in the same class instead, or sometimes they may use two medicines in the one class.


    input double pat_id int year str7 ATCcode str5 atc4th int(yearsupply_initiated yearsupply_ended yeargroup_initiated yeargroup_ended) byte(dispensed_q1 dispensed_q2 dispensed_q3 dispensed_q4)
    17629 2012 "c09ca04" "c09ca" 19097 19279 19097 19279 0 1 1 1
    17629 2013 "c09ca04" "c09ca" 19307 19687 19307 19687 1 1 1 1
    17629 2014 "c09ca04" "c09ca" 19720 20048 19720 20048 1 1 1 1
    17629 2015 "c09ca04" "c09ca" 20080 20444 20080 20444 1 1 1 1
    17629 2016 "c09ca04" "c09ca" 20234 20803 20234 20803 1 1 1 1
    17629 2017 "c09ca04" "c09ca" 20833 21132 20833 21132 1 1 1 1
    17629 2018 "c09ca04" "c09ca" 21166 21523 21166 21523 1 1 1 1
    17629 2019 "c09ca04" "c09ca" 21556 21820 21556 21820 1 1 1 0
    17629 2020 "c09ca04" "c09ca" 21944 22212 21944 22212 1 1 1 1
    17629 2021 "c09ca04" "c09ca" 22270 22576 22270 22576 1 1 1 1
    17629 2012 "h03aa01" "h03aa" 19240 19240 19240 19240 0 0 1 0
    17629 2013 "h03aa01" "h03aa" 19438 19438 19438 19438 1 0 0 0
    17629 2014 "h03aa01" "h03aa" 20045 20045 20045 20045 0 0 0 1
    17629 2015 "h03aa01" "h03aa" 20275 20275 20275 20275 0 0 1 0
    17629 2016 "h03aa01" "h03aa" 20511 20730 20511 20730 1 0 0 1
    17629 2017 "h03aa01" "h03aa" 20928 21120 20928 21120 0 1 0 1
    17629 2018 "h03aa01" "h03aa" 21327 21523 21327 21523 0 1 0 1
    17629 2020 "h03aa01" "h03aa" 21920 22113 21920 22113 1 0 1 0
    17629 2021 "h03aa01" "h03aa" 22305 22484 22305 22484 1 0 1 0
    17629 2013 "m01ac06" "m01ac" 19614 19614 19614 19614 0 0 1 0
    17629 2016 "m05ba07" "m05ba" 20499 20499 20499 20499 1 0 0 0
    26225 2012 "a01ab11" "a01ab" 19283 19283 19283 19283 0 0 0 1
    26225 2013 "a01ab11" "a01ab" 19292 19417 19292 19417 1 0 0 1
    26225 2014 "a03fa01" "a03fa" 19475 19475 19475 19475 0 1 0 0
    26225 2010 "a10ba02" "a10ba" 18280 18547 18280 18547 1 1 1 1
    26225 2011 "a10ba02" "a10ba" 18586 18929 18586 18929 1 1 1 1
    26225 2012 "a10ba02" "a10ba" 18939 19283 18939 19283 1 1 1 1
    26225 2013 "a10ba02" "a10ba" 19292 19489 19292 19489 1 1 0 1
    26225 2014 "a10ba02" "a10ba" 19535 19745 19535 19745 1 1 1 1
    26225 2010 "a10bb09" "a10bb" 18265 18523 18265 18523 1 1 1 0
    26225 2011 "a10bb09" "a10bb" 18576 18929 18576 18929 1 1 1 1
    26225 2012 "a10bb09" "a10bb" 18954 19283 18954 19283 1 1 1 1
    26225 2013 "a10bb09" "a10bb" 19292 19462 19292 19462 1 1 0 1
    26225 2014 "a10bb09" "a10bb" 19493 19751 19493 19751 1 1 1 1
    26225 2012 "b01ac04" "b01ac" 19283 19283 18942 19283 0 1 1 1
    26225 2013 "b01ac04" "b01ac" 19292 19437 19292 19437 1 0 0 1
    26225 2014 "b01ac04" "b01ac" 19466 19745 19466 19745 1 1 1 1
    26225 2012 "b01ac06" "b01ac" 18942 19187 18942 19283 0 1 1 1
    26225 2014 "c03ca01" "c03ca" 19511 19704 19511 19704 0 1 1 1
    26225 2010 "c08ca02" "c08ca" 18280 18547 18280 18547 1 1 1 1
    26225 2011 "c08ca02" "c08ca" 18576 18926 18576 18926 1 1 1 1
    26225 2012 "c08ca02" "c08ca" 18954 19283 18954 19283 1 1 1 1
    26225 2013 "c08ca02" "c08ca" 19292 19489 19292 19489 1 1 0 1
    26225 2014 "c08ca02" "c08ca" 19523 19724 19523 19724 1 1 1 1
    26225 2010 "c09aa05" "c09aa" 18265 18562 18265 18562 1 1 1 1
    26225 2011 "c09aa05" "c09aa" 18586 18912 18586 18912 1 1 1 1
    26225 2012 "c09aa05" "c09aa" 18939 19283 18939 19283 1 1 1 1
    26225 2013 "c09aa05" "c09aa" 19292 19504 19292 19504 1 1 0 1
    26225 2014 "c09aa05" "c09aa" 19531 19733 19531 19733 1 1 1 1
    26225 2010 "c10aa05" "c10aa" 18265 18520 18265 18520 1 1 1 0
    26225 2011 "c10aa05" "c10aa" 18586 18926 18586 18926 1 1 1 1
    26225 2012 "c10aa05" "c10aa" 19052 19283 19052 19283 1 1 1 1
    26225 2013 "c10aa05" "c10aa" 19292 19410 19292 19410 1 0 0 1
    26225 2014 "c10aa05" "c10aa" 19431 19733 19431 19733 1 1 1 1
    26225 2011 "j01cr02" "j01cr" 18612 18612 18612 18612 0 0 0 1
    26225 2014 "j01cr02" "j01cr" 19751 19751 19751 19751 1 0 0 0
    26225 2013 "j01db01" "j01db" 19308 19395 19308 19395 1 0 0 1
    26225 2014 "j01db01" "j01db" 19674 19709 19674 19709 0 0 0 1
    26225 2014 "j01xd01" "j01xd" 19751 19751 19751 19751 1 0 0 0
    26225 2013 "n02aa05" "n02aa" 19421 19421 19421 19421 1 0 0 0
    26225 2013 "n02ae01" "n02ae" 19421 19431 19421 19431 1 0 0 0
    26225 2014 "n02ae01" "n02ae" 19450 19753 19450 19753 1 1 1 1
    26225 2012 "n05cd07" "n05cd" 18947 18947 18947 18947 0 0 0 1
    26225 2013 "n05cd07" "n05cd" 19305 19415 19305 19415 1 0 0 1
    26225 2014 "n05cd07" "n05cd" 19437 19745 19437 19745 1 1 1 1
    26225 2012 "s01aa01" "s01aa" 18947 19031 18947 19031 1 0 0 1
    26225 2012 "s01bb02" "s01bb" 19031 19031 19031 19031 1 0 0 0
    end
    format %td yearsupply_initiated
    format %td yearsupply_ended
    format %td yeargroup_initiated
    format %td yeargroup_ended
    label var pat_id "Patient Id"
    label var ATCcode "ATC5_Code"
    label var yearsupply_initiated "Last year of supply"
    label var yeargroup_initiated "First year of supply"
    label var yeargroup_ended "Last year of supply"

  • #2
    It would help to have a more complete description of your variables. E.g. how do we interpret the yearsupply_initiated and yearsupply_ended variables (and the corresponding group variables). I do not understand when yearsupply_initiated takes different values for the same medicine and the same person across years, and also often has values from the preceding year.

    It would also help if you showed us the expected output for some cases.

    Comment


    • #3
      My apologies. There is another variable that I forgot to put in the output which is supplydate, which is each individual time the medicine is supplied. Data are in long form using supplydate as each separate supply being a new observation.
      The variables yearsupply_initiated and yearsupply_ended variables are the first and last date of supply by year for each unique medicine. If the medicine was supplied only one time, this will be the same date for yearsupply_initiated and yearsupply_ended. Where the medicine was supplied two or more times, the value will correspond to the first and last supply time for the year.
      The corresponding group variable (yeargroup_initiated and yeargroup_ended) is the first and last supply date for the pharmacological class at the ATC level 4. If the observation were the first and only medicine supplied in the class, then yearsupply_initiated and yeargroup_initiated will be the same and yearsupply_ended and yeargroup_ended will be the same. Where more than one medicine from the same class (ATC level 4) is supplied, these values may be different as the medicine could have been supplied on different days.
      The dates are perturbed, but always in a consistent direction for each individual, which is why some show values from the preceding or following year.

      I will use an examples to try and show what I'm trying to achieve:

      I want to create three new variables:
      New variable name Values
      switch 0 (first time any medicine in the class was supplied),
      1 (switched from a previous medicine in the same class that is now discontinued)
      2 (first time the unique medicine is supplied, but supplied concurrently with another medicine in the same class)
      discontinue 0 (supply is ongoing, with most recent supplydate being in the most recent quarter, so dispensed in 2021 quarter 3 (dispensed_q3)
      1 (supply discontinued, there's a break of at least 45 days in supply),
      2 (supply discontinued, but another medicine in the same class was started instead)
      restart 0 (no)
      1 (a medicine that had been discontinued is then supplied again)
      (nb I have a good example that was randomly pulled out with dataex in the sample data for the first part, but it didn't pull out a similarly nice example for the second part. I will try and illustrate the second component using the ATC level 3 so I can use the example data instead)
      e.g
      Person 26225 has aspirin (ATC code b01ac06, and the atc level 4 is b01ac) and clopidogrel (ATC code b01ac04, and the atc level 4 is b01ac) in the dataset. They use aspirin (b01ac06) from 11 November 2011 to 13 July 2012. On 17 October 2012, the supply for clopidogrel starts and aspirin is not supplied again. I want to create a variable named switch where 1 flags clopidogrel (the second medicine supplied in the class) as switched from another medicine in the same class or 0 tells me that it's the first time the person has had a medicine in that class supplied.

      Person 26225 has metformin (ATC code a10ba02, and the atc level 3 is a10b) and gliclazide (ATC code a10bb09, and the atc level 3 is a10b) in the dataset. They initiate metformin on the 18 January 2010 and use it through to 22jan2014 On 03jan2010, the supply for gliclazide starts and it is supplied 28jan2014. I want the variable named switch to have a different value (2) flags gliclazide (the second medicine supplied in the class) as a new medicine rather than one that has been started because another one in the same)

      Person 17629 discontinued levothyroxine (ATCcode h03aa01) in 2018 with the last supply date being 05dec2018. However, the supply restarted in 2020 with a new dispense date on 06jan2020. I want to create an indicator variable that flags this as a recommenced medicine.

      My intention is that I will then be able to use these variables to identify how many medicines a person is using concurrently, and to determine persistence with medicines.
      Is this any clearer?

      Comment

      Working...
      X