How to get R to parse the <study_design> field from clinicaltrials.gov XML files

by

Clinicaltrials.gov helpfully provides a facility for downloading machine-readable XML files of its data. Here’s an example of a zipped file of 10 clinicaltrials.gov XML files.

Unfortunately, a big zipped folder of XML files is not that helpful. Even after parsing a whole bunch of trials into a single data frame in R, there are a few fields that are written in the least useful format ever. For example, the <study_design> field usually looks something like this:

Allocation: Non-Randomized, Endpoint Classification: Safety Study, Intervention Model: Single Group Assignment, Masking: Open Label, Primary Purpose: Treatment

So, I wrote a little R script to help us all out. Do a search on clinicaltrials.gov, then save the unzipped search result in a new directory called search_result/ in your ~/Downloads/ folder. The following script will parse through each XML file in that directory, putting each one in a new data frame called “trials”, then it will explode the <study_design> field into individual columns.

So for example, based on the example field above, it would create new columns called “Allocation”, “Endpoint_Classification”, “Intervention_Model”, “Masking”, and “Primary_Purpose”, populated with the corresponding data.

require ("XML")
require ("plyr")

# Change path as necessary
path = "~/Downloads/search_result/"

setwd(path)
xml_file_names <- dir(path, pattern = ".xml")

counter <- 1

# Makes data frame by looping through every XML file in the specified directory
for ( xml_file_name in xml_file_names ) {
  
  xmlfile <- xmlTreeParse(xml_file_name)
  
  xmltop <- xmlRoot(xmlfile)
  
  data <- xmlSApply(xmltop, function(x) xmlSApply(x, xmlValue))
  
  if ( counter == 1 ) {
    
    trials <- data.frame(t(data), row.names = NULL)
    
  } else {
    
    newrow <- data.frame(t(data), row.names = NULL)
    trials <- rbind.fill (trials, newrow)
    
  }
  
  # This will be good for very large sets of XML files
  
  print (
    paste0(
      xml_file_name,
      " processed (",
      format(100 * counter / length(xml_file_names), digits = 2),
      "% complete)"
    )
  )
  
  counter <- counter + 1
  
}

# Data frame has been constructed. Comment out the following two loops
# (until the "un-cluttering" part) in the case that you are not interested
# in exploding the <study_design> column.

columns = vector();

for ( stu_des in trials$study_design ) {
  # splits by commas NOT in parentheses
  for (pair in strsplit( stu_des, ", *(?![^()]*\\))", perl=TRUE)) {
    newcol <- substr( pair, 0, regexpr(':', pair) - 1 )
    columns <- c(columns, newcol)
  }
}

for ( newcol in unique(columns) ) {
  
  # get rid of spaces and special characters
  newcol <- gsub('([[:punct:]])|\\s+','_', newcol)
  
  if (newcol != "") {
    
    # add the new column
    trials[,newcol] <- NA
    
    i <- 1
    
    for ( stu_des2 in trials$study_design ) {
      
      for (pairs in strsplit( stu_des2, ", *(?![^()]*\\))", perl=TRUE)) {
        
        for (pair in pairs) {
          
          if ( gsub('([[:punct:]])|\\s+','_', substr( pair, 0, regexpr(':', pair) - 1 )) == newcol ) {
            
            trials[i, ncol(trials)] <- substr( pair, regexpr(':', pair) + 2, 100000 )
            
          }
          
        }
        
      }
      
      i <- i+1
      
    }
    
  }
  
}

# Un-clutter the working environment

remove (i)
remove (counter)
remove (data)
remove (newcol)
remove (newrow)
remove (columns)
remove (pair)
remove (pairs)
remove (stu_des)
remove (stu_des2)
remove (xml_file_name)
remove (xml_file_names)
remove (xmlfile)
remove (xmltop)

# Get nice NCT id's

get_nct_id <- function ( row_id_info ) {
  
  return (unlist (row_id_info) ["nct_id"])
  
}

trials$nct_id <- lapply(trials$id_info, function(x) get_nct_id (x))

# Clean up enrolment field

trials$enrollment[trials$enrollment == "NULL"] <- NA

trials$enrollment <- as.numeric(trials$enrollment)

Useful references:

  • https://www.r-bloggers.com/r-and-the-web-for-beginners-part-ii-xml-in-r/
  • http://stackoverflow.com/questions/3402371/combine-two-data-frames-by-rows-rbind-when-they-have-different-sets-of-columns
  • http://stackoverflow.com/questions/21105360/regex-find-comma-not-inside-quotes

BibTeX

@online{bgcarlisle2016-4738,
    title = {How to get R to parse the <study_design> field from clinicaltrials.gov XML files},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2016-10-6,
    url = {https://www.bgcarlisle.com/blog/2016/10/06/how-to-get-r-to-parse-the-study-design-field-from-clinicaltrials-gov-xml-files/}
}

MLA

Carlisle, Benjamin Gregory. "How to get R to parse the <study_design> field from clinicaltrials.gov XML files" Web blog post. The Grey Literature. 06 Oct 2016. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2016/10/06/how-to-get-r-to-parse-the-study-design-field-from-clinicaltrials-gov-xml-files/>

APA

Carlisle, Benjamin Gregory. (2016, Oct 06). How to get R to parse the <study_design> field from clinicaltrials.gov XML files [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2016/10/06/how-to-get-r-to-parse-the-study-design-field-from-clinicaltrials-gov-xml-files/


It’s Movember! Review your knowledge of Bayes’ theorem before getting your PSA test.

by

Background info

There are 3 million in the U.S. currently living with prostate cancer. There are approximately 320 million people in the US today, roughly half of whom will have prostates. Hence, let us take the prevalence of prostate cancer among those who have prostates to be approximately 3 in 160, or just under 2%.

The false positive (type I error) rate is reported at 33% for PSA velocity screening, or as high as 75%. The false negative (type II error) rate is reported as between 10-20%. For the purpose of this analysis, let’s give the PSA test the benefit of the doubt, and attribute to it the lowest type I and type II error rates, namely 33% and 10%.

Skill testing question

If some random person with a prostate from the United States, where the prevalence of prostate cancer is 2%, receives a positive PSA test result, where that test has a false positive rate of 33% and a false negative rate of 10%, what is the chance that this person actually has prostate cancer?

Bayes’ theorem

Recall Bayes’ theorem from your undergraduate Philosophy of Science class. Let us define the hypothesis we’re interested in testing and the evidence we are considering as follows:

P(h): The prior probability that this person has cancer
P(e|¬h): The false positive (type I error) rate
P(¬e|h): The false negative (type II error) rate

P(h) = 3/160
P(e|¬h) = 0.33
P(¬e|h) = 0.10

Given these definitions, the quantity we are interested in calculating is P(h|e), the probability that the person has prostate cancer, given that he returns a positive PSA test result. We can calculate this value using the following formulation of Bayes’ theorem:

P(h|e) = P(h) / [ P(h) + ( P(e|¬h) P(¬h) ) / ( P(e|h) ) ]

From the above probabilities and the laws of probability, we can derive the following missing quantities.

P(¬h) = 1 – 3/160
P(e|h) = 0.90

These can be inserted into the formula above. The answer to the skill-testing question is that there is a 4.95% chance that the randomly selected person in question will have prostate cancer, given a positive PSA test result.

What if we know more about the person in question?

Let’s imagine that the person is not selected at random. Say that this person is a man with a prostate and he is over 60 years old.

According to Zlotta et al, the prevalence of prostate cancer rises to over 40% in men over age 60. If we redo the above calculation with this base rate, P(h) = 0.40, we find that P(h|e) rises to 64.5%.

Take-home messages

  1. Humans are very bad at intuiting probabilities. See Wikipedia for recommended reading on the Base Rate Fallacy.
  2. Having a prostate is neither a necessary nor a sufficient condition for being a man. Just FYI.
  3. Don’t get tested for prostate cancer unless you’re in a higher-risk group, because the base rate of prostate cancer is so low in the general population that if you get a positive result, it’s likely to be a false positive.

BibTeX

@online{bgcarlisle2015-4639,
    title = {It’s Movember! Review your knowledge of Bayes’ theorem before getting your PSA test.},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2015-11-18,
    url = {https://www.bgcarlisle.com/blog/2015/11/18/its-movember-review-your-knowledge-of-bayes-theorem-before-getting-your-psa-test/}
}

MLA

Carlisle, Benjamin Gregory. "It’s Movember! Review your knowledge of Bayes’ theorem before getting your PSA test." Web blog post. The Grey Literature. 18 Nov 2015. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2015/11/18/its-movember-review-your-knowledge-of-bayes-theorem-before-getting-your-psa-test/>

APA

Carlisle, Benjamin Gregory. (2015, Nov 18). It’s Movember! Review your knowledge of Bayes’ theorem before getting your PSA test. [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2015/11/18/its-movember-review-your-knowledge-of-bayes-theorem-before-getting-your-psa-test/


I’m just gonna throw it out there—vaccine denialism technically fits the Canadian Criminal Code’s definition for “terrorist activity”

by

I’m going to preface this by saying that I’m not a lawyer, and this post is meant more for comic effect than to be an actual attempt at a serious legal analysis. With that caveat firmly in place, maybe we can use some of these terrible new anti-terrorism powers that the government has given itself to combat vaccine denialism?

Section Quote from Criminal Code Does it apply to vaccine denialists?
83.01 (1) “Terrorist activity” means …
(b) … an act or omission, in or outside Canada … Failing to vaccinate one’s child, or advocating against the vaccination of children counts as an act or omission committed in or outside Canada.
(i) (A) … that is committed in whole or in part for a political, religious or ideological purpose, objective or cause, and … This definitely counts as “political” and “ideological.”
(i) (B) … in whole or in part with the intention of intimidating the public, or a segment of the public, with regard to its security, including its economic security, or compelling a person, a government or a domestic or an international organization to do or to refrain from doing any act, whether the public or the person, government or organization is inside or outside Canada, and … While the intention is not to intimidate anyone with regard to their security, advocating for a position that denies the clear consensus of the scientific community with regard to vaccine safety certainly does have the intention of compelling a person to refrain from an act, namely, vaccinating a child, which meets this definition. There are also other actors (doctors, teachers, etc.) who are also targets of this movement.
(ii) (C) … that intentionally … causes a serious risk to the health or safety of the public or any segment of the public Vaccine denialism does cause a serious risk to the health and safety of the public.
Source: Criminal Code, RSC 1985, c C-46

BibTeX

@online{bgcarlisle2015-4412,
    title = {I’m just gonna throw it out there—vaccine denialism technically fits the Canadian Criminal Code’s definition for “terrorist activity”},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2015-02-6,
    url = {https://www.bgcarlisle.com/blog/2015/02/06/vaccine-denialism-technically-fits-the-canadian-criminal-codes-definition-for-terrorist-activity/}
}

MLA

Carlisle, Benjamin Gregory. "I’m just gonna throw it out there—vaccine denialism technically fits the Canadian Criminal Code’s definition for “terrorist activity”" Web blog post. The Grey Literature. 06 Feb 2015. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2015/02/06/vaccine-denialism-technically-fits-the-canadian-criminal-codes-definition-for-terrorist-activity/>

APA

Carlisle, Benjamin Gregory. (2015, Feb 06). I’m just gonna throw it out there—vaccine denialism technically fits the Canadian Criminal Code’s definition for “terrorist activity” [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2015/02/06/vaccine-denialism-technically-fits-the-canadian-criminal-codes-definition-for-terrorist-activity/


An unexpected link between computer science and the ethics of consent in the acutely comatose

by

Yesterday, Dr Weijer from Western U came to the STREAM research group at McGill to give a talk on the ethics of fMRI studies on acutely comatose patients in the intensive care unit. One of the topics he briefly covered (not the main topic of his talk) was that of patients who may be “awake,” but generally unaware of their surroundings, while in an acutely comatose state of some kind. Using an fMRI, questions can be asked of some of these subjects, by telling them to imagine playing tennis for “yes,” and to imagine navigating their home for “no.” Since the areas of the brain for these two tasks are very different, these can be used to distinguish responses with some accuracy. In some rare cases, patients in this condition are able to consistently answer biographical questions, indicating that they are in some sense, conscious.

One of the questions that arises is: Could we use this method to involve a comatose patient in decision-making regarding her own care, in cases where we were able to establish this sort of communication?

Informed consent in medical ethics is usually conceived in terms of: disclosure, capacity and voluntariness, and the most obvious question to arise in the types of cases we’re considering is whether or not you could ever know with certainty that a comatose person has the capacity to make such decisions in such a state. (Indeed, a comatose patient is often the example given of someone who does not have the capacity to consent.) Dr Weijer was generally sceptical on that front.

Partway through his discussion, I had the impression that the problem was strangely familiar. If we abstract away some of the details of the situation in question, we are left with an experimenter who is sending natural language queries into a black box system, which replies with a digital (0/1) output, and then the experimenter has to make the best evaluation she can as to whether the black box contains a person, or if it is just an “automatic” response of some kind.

For those of you with some background in computer science, you will recognise this as the Turing Test. Over the 65 years since it was first suggested, for one reason or another, most people have abandoned the Turing Test as a way to address the question of artificial intelligence, although it still holds a certain popular sway, as claims of chatbots that can beat the Turing Test still make the news. While many would reject that it is even an important question whether a chatbot can make you believe it is a person, at least in the fMRI/coma patient version, no one can dispute whether there is something important at stake.

BibTeX

@online{bgcarlisle2015-4345,
    title = {An unexpected link between computer science and the ethics of consent in the acutely comatose},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2015-01-13,
    url = {https://www.bgcarlisle.com/blog/2015/01/13/an-unexpected-link-between-computer-science-and-the-ethics-of-consent-in-the-acutely-comatose/}
}

MLA

Carlisle, Benjamin Gregory. "An unexpected link between computer science and the ethics of consent in the acutely comatose" Web blog post. The Grey Literature. 13 Jan 2015. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2015/01/13/an-unexpected-link-between-computer-science-and-the-ethics-of-consent-in-the-acutely-comatose/>

APA

Carlisle, Benjamin Gregory. (2015, Jan 13). An unexpected link between computer science and the ethics of consent in the acutely comatose [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2015/01/13/an-unexpected-link-between-computer-science-and-the-ethics-of-consent-in-the-acutely-comatose/


So I started learning Lojban .ui

by

This Friday past, I started learning Lojban. For the non-initiate, Lojban is a constructed language based on predicate logic that is syntactically unambiguous. I’d known about it for years, probably hearing about it first on CBC, maybe 10 years ago. It’s the sort of thing that shows up in Dinosaur Comics or in XKCD periodically. Up until this weekend, the existence of Lojban had mostly been one of those “cocktail party facts,” but then I finally took the plunge. After 1 weekend of working on it, I’m about 35% of the way through Lojban for Beginners, having downloaded it to my Kobo for reference during the car ride to Stratford.

It’s often billed as being an ideal language for fields like law, science or philosophy, due to its unambiguous and culturally neutral nature. So I set out to find out certain specialised terms from my field, bioethics, and it turns out that they mostly don’t exist yet. This, of course, offers some exciting opportunities for a grad student. :)

I’ve convinced a few people in Montréal to learn Lojban with me, and even found a Montrealer who speaks Lojban on a #lojban IRC channel. (Yes, IRC still exists!) We may “ckafi pinxe kansa,” as they say in Lojban, apparently.

If you too want to get in on the ground floor of Lojban Montréal, let me know!

BibTeX

@online{bgcarlisle2014-4260,
    title = {So I started learning Lojban .ui},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2014-09-22,
    url = {https://www.bgcarlisle.com/blog/2014/09/22/so-i-started-learning-lojban-ui/}
}

MLA

Carlisle, Benjamin Gregory. "So I started learning Lojban .ui" Web blog post. The Grey Literature. 22 Sep 2014. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2014/09/22/so-i-started-learning-lojban-ui/>

APA

Carlisle, Benjamin Gregory. (2014, Sep 22). So I started learning Lojban .ui [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2014/09/22/so-i-started-learning-lojban-ui/


Proof of prespecified endpoints in medical research with the bitcoin blockchain

by

Introduction

The gerrymandering of endpoints or analytic strategies in medical research is a serious ethical issue. “Fishing expeditions” for statistically significant relationships among trial data or meta-analytic samples can confound proper inference by statistical multiplicity. This may undermine the validity of research findings, and even threaten a favourable balance of patient risk and benefit in certain clinical trials. “Changing the goalposts” for a clinical trial or a meta-analysis when a desired endpoint is not reached is another troubling example of a potential scientific fraud that is possible when endpoints are not specified in advance.

Pre-specifying endpoints

Choosing endpoints to be measured and analyses to be performed in advance of conducting a study is a hallmark of good research practice. However, if a protocol is published on an author’s own web site, it is trivial for an author to retroactively alter her own “pre-specified” goals to align with the objectives pursued in the final publication. Even a researcher who is acting in good faith may find it less than compelling to tell her readers that endpoints were pre-specified, with only her word as a guarantee.

Advising a researcher to publish her protocol in an independent venue such as a journal or a clinical trial registry in advance of conducting research does not solve this problem, and even creates some new ones. Publishing a methods paper is a lengthy and costly process with no guarantee of success—it may not be possible to find a journal interested in publishing your protocol.

Pre-specifying endpoints in a clinical trial registry may be feasible for clinical trials, but these registries are not open to meta-analytic projects. Further, clinical trial registry entries may be changed, and it is much more difficult (although still possible) to download previous versions of trial registries than it is to retrieve the current one. For example, there is still no way to automate downloading of XML-formatted historical trial data from www.clinicaltrials.gov in the same way that the current version of trial data can be automatically downloaded and processed. Burying clinical trial data in the “history” of a registry is not a difficult task.

Publishing analyses to be performed prior to executing the research itself potentially sets up a researcher to have her project “scooped” by a faster or better-funded rival research group who finds her question interesting.

Using the bitcoin blockchain to prove a document’s existence at a certain time

Bitcoin uses a distributed, permanent, timestamped, public ledger of all transactions (called a “blockchain”) to establish which addresses have been credited with how many bitcoins. The blockchain indirectly provides a method for establishing the existence of a document at particular time that can be independently verified by any interested party, without relying on a medical researcher’s moral character or the authority (or longevity) of a central registry. Even in the case that the NIH’s servers were destroyed by a natural disaster, if there were any full bitcoin nodes left running in the world, the method described below could be used to confirm that a paper’s analytic method was established at the time the authors claim.

Method

  1. Prepare a document containing the protocol, including explicitly pre-specified endpoints and all prospectively planned analyses. I recommend using a non-proprietary document format (e.g. an unformatted text file or a LaTeX source file).
  2. Calculate the document’s SHA256 digest and convert it to a bitcoin private key.
  3. Import this private key into a bitcoin wallet, and send an arbitrary amount of bitcoin to its corresponding public address. After the transaction is complete, I recommend emptying the bitcoin from that address to another address that only you control, as anyone given the document prepared in (1) will have the ability to generate the private key and spend the funds you just sent to it.

Result

The incorporation into the blockchain of the first transaction using the address generated from the SHA256 digest of the document provides an undeniably timestamped record that the research protocol prepared in (1) is at least as old as the transaction in question. Care must be taken not to accidentally modify the protocol after this point, since only an exact copy of the original protocol will generate an identical SHA256 digest. Even the alteration of a single character will make the document fail an authentication test.

To prove a document’s existence at a certain point in time, a researcher need only provide the document in question. Any computer would be able to calculate its SHA256 digest and convert to a private key with its corresponding public address. Anyone can search for transactions on the blockchain that involve this address, and check the date when the transaction happened, proving that the document must have existed at least as early as that date.

Discussion

This strategy would prevent a researcher from retroactively changing an endpoint or adding / excluding analyses after seeing the results of her study. It is simple, economical, trustless, non-proprietary, independently verifiable, and provides no opportunity for other researchers to steal the methods or goals of a project before its completion.

Unfortunately, this method would not prevent a malicious team of researchers from preparing multiple such documents in advance, in anticipation of a need to defraud the medical research establishment. To be clear, under a system as described above, retroactively changing endpoints would no longer be a question of simply deleting a paragraph in a Word document or in a trial registry. This level of dishonesty would require planning in advance (in some cases months or years), detailed anticipation of multiple contingencies, and in many cases, the cooperation of multiple members of a research team. At that point, it would probably be easier to just fake the numbers than it would be to have a folder full of blockchain-timestamped protocols with different endpoints, ready in case the endpoints need to be changed.

Further, keeping a folder of blockchain-timestamped protocols would be a very risky pursuit—all it would take is a single honest researcher in the lab to find those protocols, and she would have a permanent, undeniable and independently verifiable proof of the scientific fraud.

Conclusion

Fraud in scientific methods erodes confidence in the medical research establishment, which is essential to it performing its function—generating new scientific knowledge, and cases where pre-specified endpoints are retroactively changed casts doubt on the rest of medical research. A method by which anyone can verify the existence of a particular detailed protocol prior to research would lend support to the credibility of medical research, and be one less thing about which researchers have to say, “trust me.”

BibTeX

@online{bgcarlisle2014-4232,
    title = {Proof of prespecified endpoints in medical research with the bitcoin blockchain},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2014-08-25,
    url = {https://www.bgcarlisle.com/blog/2014/08/25/proof-of-prespecified-endpoints-in-medical-research-with-the-bitcoin-blockchain/}
}

MLA

Carlisle, Benjamin Gregory. "Proof of prespecified endpoints in medical research with the bitcoin blockchain" Web blog post. The Grey Literature. 25 Aug 2014. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2014/08/25/proof-of-prespecified-endpoints-in-medical-research-with-the-bitcoin-blockchain/>

APA

Carlisle, Benjamin Gregory. (2014, Aug 25). Proof of prespecified endpoints in medical research with the bitcoin blockchain [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2014/08/25/proof-of-prespecified-endpoints-in-medical-research-with-the-bitcoin-blockchain/


CBC’s “Dr C” and the problem of doctor-centred care

by

A CBC-hosted blog has been following the story of “Dr C.” CBC describes him as “a St. John’s physician training in internal medicine. He’s also a writer, and he’s documenting his life since being diagnosed with cancer.” His blog posts show up on the CBC Health twitter account periodically, and they pass through my newsreader on a fairly regular basis.

For the last few months, I felt uncomfortable every time I saw one of his blog posts go by, and I couldn’t put my finger on why that might be. I think today I can finally articulate my misgivings.

A doctor’s privilege

I feel like the underlying assumption for CBC’s intense coverage, and the voice that “Dr C” has in expressing his experience with cancer is that when it’s a doctor who is diagnosed with cancer, he will have some interesting insights on the matter. In fact that’s the whole premiss of the “Dr C” blog. This makes me uncomfortable because in the modern medical system, a doctor’s voice is always the most important.

Fortunately, this is less the case than it used to be, to be sure. It used to be that nurses were trained to stand up out of respect when a doctor entered a hospital room, for example. But even today in 2014, the opinion of a doctor is, on the last analysis, the only one that really matters in the healthcare system, and in a lot of ways, that shouldn’t be the case.

What is patient-centred care?

Before a conspiracy theorist mistakes what I’m writing about, I want to clarify that I’m not saying that an untrained quack should be given the same voice as a medical doctor on issues like vaccine safety, or the efficacy of “alternative” medical therapies. I’m not advocating for that at all. I’m fully on the side of medical science, and I have rather mainstream views on that matter, even though I work in the Medical Ethics Unit. (It turns out that the real evils of drug development and medical practice are rather mundane things, mostly done under the light of peer-reviewed scrutiny. Go figure.)

What I’m talking about is patient-centred healthcare, a concept that most medical professionals agree on, or at least pay lip-service to. It is a somewhat nebulous umbrella concept, and it is aspirational in nature—a healthcare worker can always try to be more patient-centred.

The idea itself is not controversial. Every healthcare worker would likely say that she wants to be patient-centred, and this includes things like catering her care toward the patient’s own idiosyncratic values, taking into account the patient’s strengths, and seeing the patient’s family as the unit of care, rather than maintaining the fiction that it is possible to treat a disease process in an individual without regard for the rest of the patient’s life.

So what’s the problem with Dr C’s blog?

I have nothing against “Dr C” from the CBC. I think it’s terrible that he (or anyone) has cancer, and I wish him the best in his treatment and recovery. I’m even glad that his blog has given him a place to work through his thoughts. I hope that he’s a more sympathetic physician as a result, and that his insights have helped other people to deal with their own cancer diagnoses.

That said, I feel like the way in which a doctor’s opinions are privileged in any discussion on healthcare is very troubling, and I can’t shake the feeling that this blog pushes it even one step further. It’s as if they’re saying that privileging a doctor’s voice when he’s the one treating the cancer isn’t enough. We also have to get a doctor to tell us what it’s like to be a patient as well, because then it will be something worth listening to.

BibTeX

@online{bgcarlisle2014-3909,
    title = {CBC’s “Dr C” and the problem of doctor-centred care},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2014-01-6,
    url = {https://www.bgcarlisle.com/blog/2014/01/06/cbcs-dr-c-and-the-problem-of-doctor-centred-care/}
}

MLA

Carlisle, Benjamin Gregory. "CBC’s “Dr C” and the problem of doctor-centred care" Web blog post. The Grey Literature. 06 Jan 2014. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2014/01/06/cbcs-dr-c-and-the-problem-of-doctor-centred-care/>

APA

Carlisle, Benjamin Gregory. (2014, Jan 06). CBC’s “Dr C” and the problem of doctor-centred care [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2014/01/06/cbcs-dr-c-and-the-problem-of-doctor-centred-care/


How to automatically back up WordPress or ownCloud using cron jobs

by

Recently I set up WordPress for my research group in the Medical Ethics Unit. We will be blogging our journal clubs, posting links to our publications and upcoming events. In related news, my research group has been using DropBox to coordinate papers in progress, sharing of raw data, citations, and all manner of other information. This was working pretty well, but we have been bumping up against the upper limit of our capacity on DropBox for a while, so I installed ownCloud on the web host we got for the research group blog. I’m pretty happy with how nice it is to use and administer.

Of course one of our concerns is making sure that we don’t lose any data in the case of the failure of our web host. This is unlikely, but it does happen, and we don’t want to run into a situation where we try to log in to our cloud-based file storage / sharing service and find that months’ worth of research is gone forever.

For a few weeks, the following was more-or-less my workflow for making backups:

  1. Log in to phpMyAdmin
  2. Make a dump file of the WP database (choose database > Export > Save as file … )
  3. Make a dump file of the ownCloud database
  4. Save to computer and label with appropriate date
  5. Log in to web server using FTP
  6. Copy contents of WP’s /wp-content/ to a date-labelled folder on my computer
  7. Copy contents of ownCloud’s /data/ to a date-labelled folder on my computer

This worked pretty well, except that it was a pain for me to have to do this every day, and I know that if I ever forgot to do it, that would be when something terrible happened. Fortunately for me, my boss mentioned that he had an old but still serviceable iMac sitting in his office that he wanted to put to some good purpose.

I decided to make a fully automatic setup that would make backups of our remotely hosted data and save it locally without any input on my part, so I can just forget about it. I made it with cron jobs.

Server side cron jobs

First, I set up some cron jobs on the server side. The first one waits until midnight every day, then dumps all the MySQL databases into a gzipped file on my web host, then zips up the WordPress /wp-content/ and ownCloud /data/ folders and puts them in the backup folder as well. The second server-side cron job empties the backup folder every day at 23h00.

  • 0 0 * * * PREFIX=`date +%y-%m-%d`; mysqldump -u USERNAME -h HOSTNAME -pPASSWORD –all-databases | gzip > /path/to/backup/folder/${PREFIX}-DBNAME-db.sql.gz; zip -r /path/to/backup/folder/${PREFIX}-wordpress-files.zip /path/to/wordpress/wp-content/; zip -r /path/to/backup/folder/${PREFIX}-owncloud-files.zip /path/to/owncloud/data/;
  • 0 23 * * * rm -r /path/to/backup/folder/*

A few notes for someone trying to copy this set-up

  • Your web host might be in a different time zone, so you might need to keep that in mind when coordinating cron jobs on your web host with ones on a local machine.
  • My web host provided a cron job editor that automatically escapes special characters like %, but you might have to add back-slashes to make yours work if you’re manually editing with crontab -e.
  • You might want to put a .htaccess file in your backup directory with the following in it: “Options -Indexes” (remove the quotes of course). This stops other people from going to your backup directory in a browser and helping themselves to your files. You could also name your backup directory with a random hash of letters and numbers if you wanted to make it difficult for people to steal your backed-up data.

Local cron job

Then on the local machine, the old iMac, I set up the following cron job. It downloads the files and saves them to a folder on an external hard disc every day at 6h00.

  • 0 6 * * * PREFIX=`date +%y-%m-%d`; curl http://www.your-web-site.com/back-up/${PREFIX}-DBNAME-db.sql.gz > /Volumes/External HD/Back-ups/${PREFIX}-DBNAME-db.sql.gz; curl http://www.your-web-site.com/back-up/${PREFIX}-wordpress-files.zip > /Volumes/External HD/Back-ups/${PREFIX}-wordpress-files.zip; curl http://www.your-web-site.com/back-up/${PREFIX}-owncloud-files.zip > /Volumes/External HD/Back-ups/${PREFIX}-owncloud-files.zip;

If you were super-paranoid about losing data, you could install this on multiple local machines, or you change the timing so that the cron jobs run twice a day, or as often as you liked, really. As long as they’re always turned on, connected to the internet and they have access to the folder where the backups will go, they should work fine.

Stoop-n-scoop

This isn’t a super-secure way to back up your files, but then we’re more worried about losing data accidentally than having it stolen maliciously. I don’t think the world of medical ethics is cut-throat enough that our academic rivals would stoop to stealing our data in an effort to scoop our papers before we can publish them. That said, I’m not about to give away the exact URL where our backups are stored, either.

The practical upshot of all this is that now we have at least three copies of any file we’re working on. There’s one on the computer being used to edit the document, there’s one stored remotely on our web host, and there’s a copy of all our files backed up once a day on the old iMac at the Medical Ethics Unit.

BibTeX

@online{bgcarlisle2013-3552,
    title = {How to automatically back up WordPress or ownCloud using cron jobs},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2013-05-20,
    url = {https://www.bgcarlisle.com/blog/2013/05/20/how-to-automatically-back-up-wordpress-or-owncloud-using-cron-jobs/}
}

MLA

Carlisle, Benjamin Gregory. "How to automatically back up WordPress or ownCloud using cron jobs" Web blog post. The Grey Literature. 20 May 2013. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2013/05/20/how-to-automatically-back-up-wordpress-or-owncloud-using-cron-jobs/>

APA

Carlisle, Benjamin Gregory. (2013, May 20). How to automatically back up WordPress or ownCloud using cron jobs [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2013/05/20/how-to-automatically-back-up-wordpress-or-owncloud-using-cron-jobs/


A new Twitter bot for clinical [email protected]

by

So today I decided to use my powers for good and not for evil. I invented a Twitter bot, but one that’s actually useful!

Every 15 minutes, @drugtrialsbot goes to www.clinicaltrials.gov and downloads the trials from the last week that were suspended, withdrawn or terminated. Then it filters those for ones where a reason is given for its withdrawal and tweets a link to its entry in the clinical trials registry.

Here’s an example:

I find this sort of thing fascinating from a research ethics perspective.

BibTeX

@online{bgcarlisle2012-3193,
    title = {A new Twitter bot for clinical [email protected]},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2012-12-10,
    url = {https://www.bgcarlisle.com/blog/2012/12/10/a-new-twitter-bot-for-clinical-trials-drugtrialsbot/}
}

MLA

Carlisle, Benjamin Gregory. "A new Twitter bot for clinical [email protected]" Web blog post. The Grey Literature. 10 Dec 2012. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2012/12/10/a-new-twitter-bot-for-clinical-trials-drugtrialsbot/>

APA

Carlisle, Benjamin Gregory. (2012, Dec 10). A new Twitter bot for clinical [email protected] [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2012/12/10/a-new-twitter-bot-for-clinical-trials-drugtrialsbot/


Catch-22 in mental health: An open letter to Andrew Williams, CEO of Stratford General Hospital and Randy Pettapiece, MPP

by

Dear Andrew Williams and Randy Pettapiece,

Recently, my father was hospitalised for schizophrenia in the psychiatric ward at the Stratford General Hospital. This was good news. It was a welcome change after months of increasingly abusive and dangerous behaviour on his part that affected the entire family. Not only was he suffering from disordered thoughts and paranoid delusions, he lost his impulse control with regard to money (and some other things as well). Due to his condition he lacks the ability to deal with his own finances. He was admitted to the Stratford General Hospital and shortly thereafter, a medical tribunal determined that he was not competent to make his own medical decisions. My mother was assigned to be his medical decision-maker and power of attorney.

Yesterday, we found out that some unscrupulous lawyer visited the Stratford General Hospital to arrange the papers so that my dad could transfer his medical decision-making and power of attorney away from my mother, and give it to another patient on the psychiatric ward. As far as we know, this other patient is just some guy that my dad met less than two weeks ago when he was admitted. The name sounds made-up, though, so for all we know, it’s not his real name. This “other patient” could even be a delusion of my dad’s.

Needless to say, we were upset.

We contacted the lawyer to ask him what he thought he was doing. He said he didn’t do anything—that it was my dad who made it happen, and that he had training to determine when someone was competent to make such decisions. We will be inquiring about what legal options we have against this individual.

When we told our own lawyer about the problem, his administrative assistant broke out laughing, because it was such a ridiculous turn of affairs. He advised us to get a letter from dad’s psychiatrist, and on the basis of such a letter, it would be possible to have this transfer of power of attorney reversed. This seemed reasonable. On contacting the doctor, we were told that he could not release such a letter, since my dad has requested that his medical information not be shared with us (one of his paranoid delusions is that we’re out to get him), and my mother no longer had her status as his medical decision-maker and power of attorney.

In the face of this Catch-22, we’re not sure what to do next. As of today, the doctors at the Stratford General are still refusing to provide a letter indicating my dad’s condition, because they are afraid of being sued.

I’d like to emphasise at this point that the unscrupulous lawyer got paid for what he did. Paid with money. He came in to the locked ward of the Stratford General and walked out substantially richer, thanks to money he took from a person who was determined by a medical tribunal to be incapable of making his own medical decisions.

If someone walked into a hospital and found an old woman with dementia and exploited her condition for his own financial gain and gave her nothing in return, that conduct would be reprehensible, but it still wouldn’t be as bad as what this lawyer did to my dad yesterday. Not only did he take money from someone whose mental condition renders him incompetent to handle his own financial affairs, but he made it a thousand times harder for us to get my dad back on his meds to stop the paranoia and abuse.

But the really perverse part about this whole system is that if I were to march into his office and punch his face in like he deserves, somehow I would become the bad guy. (For the record, though, I would never do this.)

I have two questions. One for the CEO of the hospital and one for the MPP for Wellington-Perth.

Andrew Williams: When do your doctors plan on doing the right thing for their patient and his family?

Randy Pettapiece: What pressure are you going to bring to bear on this situation? Can you help us to ensure that the lawyer is dismissed from the bar in Ontario, and that my father receives the care he needs?

Yours angrily,

Benjamin Carlisle MA (Biomedical ethics)

Cc: Leona Aglukkaq MP, Deb Matthews MPP, Dr Brian Goldman (feel free to spread this around)

(Edit 21h00—the original version had more cursing, but as my friend advised, “Try not to swear so that your interlocutor doesn’t have an excuse to dismiss you.”)

BibTeX

@online{bgcarlisle2012-3132,
    title = {Catch-22 in mental health: An open letter to Andrew Williams, CEO of Stratford General Hospital and Randy Pettapiece, MPP},
    journaltitle = {The Grey Literature},
    author = {Benjamin Gregory Carlisle},
    address = {Montreal, Canada},
    date = 2012-11-16,
    url = {https://www.bgcarlisle.com/blog/2012/11/16/catch-22-in-mental-health/}
}

MLA

Carlisle, Benjamin Gregory. "Catch-22 in mental health: An open letter to Andrew Williams, CEO of Stratford General Hospital and Randy Pettapiece, MPP" Web blog post. The Grey Literature. 16 Nov 2012. Web. 24 May 2017. <https://www.bgcarlisle.com/blog/2012/11/16/catch-22-in-mental-health/>

APA

Carlisle, Benjamin Gregory. (2012, Nov 16). Catch-22 in mental health: An open letter to Andrew Williams, CEO of Stratford General Hospital and Randy Pettapiece, MPP [Web log post]. Retrieved from https://www.bgcarlisle.com/blog/2012/11/16/catch-22-in-mental-health/


Search

A word from our sponsors

Tag bag

Recent comments

Old posts

All content © Benjamin Carlisle