rOpenHealth / rEHR

R tools for processing and extracting clinical information from Electronic Medical Records Databases
61 stars 19 forks source link

Operation: Condition prevalence in cohort #1

Closed DASpringate closed 9 years ago

DASpringate commented 10 years ago

Condition prevalence in cohort

rosap commented 10 years ago

Would it be useful to know how many patients have only a specific condition but not another one? Example:

rosap commented 10 years ago

(continue) Therefore:

evank23 commented 10 years ago

so try to include functions for prevalence besides OR (across a code list) (OR within [code list 1]) AND NOT (OR within [code list 2]) (OR within [code list 1]) AND (OR within [code list 2]) (OR within [code list 1]) XOR (OR within [code list 2])

and might add (OR within [code list 1]) OR (OR within [code list 2]) although exactly the same as the default (but might be easier for people to use rather than merge 2 existing lists)

On 3 March 2014 15:43, Rosa notifications@github.com wrote:

(continue) Therefore:

  • Patients with psoriasis and Psoriatic Arthritis only;
  • Patients with psoriasis and Rheumatoid Arthritis only

Reply to this email directly or view it on GitHubhttps://github.com/rOpenHealth/rCPRD/issues/1#issuecomment-36522167 .

DASpringate commented 10 years ago

Yes, that would definitely be useful.

To make it more generic, I think we would do something like

select patients with codes in codelist A but not in group B

The plan is to be able to chain an arbitrary number of these selector functions together to get the final query.

So a full query might look something like this (pseudocode):

To include patients with condition A and B, but not C:

my_patients <- include_patients(db, codelist_A, startdate, enddate, condition_type = "chronic") %AND% include_patients(db, codelist_B, startdate, enddate, condition_type = "chronic") %AND% exclude_patients(db, codelist_C, startdate, enddate, condition_type = "in_window")

The condition_type argument would define the time period for selection (e.g. ignore the start time for chronic conditions) and say, whether drugs form part of the definition etc.

Note you could use the chaining commands to define different logical operators.

On 03/03/14 15:43, Rosa wrote:

(continue) Therefore:

  • Patients with psoriasis and Psoriatic Arthritis only;
  • Patients with psoriasis and Rheumatoid Arthritis only

— Reply to this email directly or view it on GitHub https://github.com/rOpenHealth/rCPRD/issues/1#issuecomment-36522167.

evank23 commented 10 years ago

yep including more than 2 is fine but remember you will need to write the documentation for all this (and I will help of course) and not everyone is as smart as we are...

On 3 March 2014 16:03, David A Springate notifications@github.com wrote:

Yes, that would definitely be useful.

To make it more generic, I think we would do something like

select patients with codes in codelist A but not in group B

The plan is to be able to chain an arbitrary number of these selector functions together to get the final query.

So a full query might look something like this (pseudocode):

To include patients with condition A and B, but not C:

my_patients <- include_patients(db, codelist_A, startdate, enddate, condition_type = "chronic") %AND% include_patients(db, codelist_B, startdate, enddate, condition_type = "chronic") %AND% exclude_patients(db, codelist_C, startdate, enddate, condition_type = "in_window")

The condition_type argument would define the time period for selection (e.g. ignore the start time for chronic conditions) and say, whether drugs form part of the definition etc.

Note you could use the chaining commands to define different logical operators.

On 03/03/14 15:43, Rosa wrote:

(continue) Therefore:

  • Patients with psoriasis and Psoriatic Arthritis only;
  • Patients with psoriasis and Rheumatoid Arthritis only

Reply to this email directly or view it on GitHub https://github.com/rOpenHealth/rCPRD/issues/1#issuecomment-36522167.

Reply to this email directly or view it on GitHubhttps://github.com/rOpenHealth/rCPRD/issues/1#issuecomment-36524619 .

rosap commented 10 years ago

I have recently found that that there are some treatment which are included as read codes rather than product codes. Just wondering if this function can include patients with a medical condition and a treatment which is however included in the Clinical file rather than the Therapy file...

rosap commented 10 years ago

Actually, it would be the same thing as selecting two conditions at the same time...

rosap commented 10 years ago

Sorry, I think I have closed the entire issue rather than my last comment

DASpringate commented 10 years ago

This is now all doable via the select_by_years and prev_totals function (apart from resolve codes at the moment). I'll write up an example for the wiki when I have some time.