help for pcdsearch

Title

pcdsearch -- A string and code search programme to extract code lists from primary care databases

Syntax

pcdsearch
filename
[, options]

where

filename the full name, with extension, of the csv or MS Excel file with the strings and codes to be searched for

Options
pcddir(string) Directory where the PCD files to be searched exist

filedir(string) Directory where the provided csv or MS Excel file exists

pcdcodefnm(string) File name for the clinical lookup file

pcdprodfnm(string) File name for the products lookup file

Description

pcdsearch aims to facilitate searching the very long lookup files accompanying Primary Care Databases (PCDs) to identify relevant clinical codes
(usually Read codes in the UK) and product codes. The command receives an MS excel file (*.xls or *.xlsx) or a comma separated values file (*.csv) as input,
containing clinical description stub strings (e.g. "asthma"), code stub strings (e.g. Read code stub "H33") and/or product(drug) description stub strings (e.g. "bambuterol").

The command needs the four strings provided by the options to operate, but an alternative approach is possible. Users can provide the information in globals
before calling pcdsearch, either in code or by editing profile.do. The four globals are pcdsourcepath, pcdoutputpath, pcdcodefilenm and pcdprodfilenm,
in place of options pcddir, filedir, pcdcodefnm or pcdprodfnm, respectively.

The search rules are desribed in detail below, along with examples using Read codes and the Clinical Practice Research Datalink (CPRD)
Gold version lookup files. Identified clinical codes and product lists are appended as additional MS Excel worksheets or saved as separate csv files, depending
on the provided file type. Worksheet names in filename are irrelevant. If an Ms Excel file the command will always import information from the first sheet.
Variable names are required (the first row is assumed to be variable names) but irrelevant. The order, however, is important and three variables/columns are
expected: (1) Clinical name stubs, (2) Clinical codes, and (3) Product name stubs

Options

pcddir(string) Directory where the Primary Care Database clinical and product lookup tables are located. Can be text or Stata files.

filedir(string) Directory where the MS Excel or csv file with the search criteria is located.

pcdcodefnm(string) Full name of Primary Care Database clinical lookup file (including extension). Can be in Stata format (*.dta) or a text file. If a text file (i.e. if the file name provided does not have a dta extension),
the file is loaded as delimited to Stata using the import command.

pcdprodfnm(string) Full name of Primary Care Database products lookup file (including extension). Can be in Stata format (*.dta) or a text file. If a text file (i.e. if the file name provided does not have a dta extension),
the file is loaded as delimited to Stata using the import command.

Remarks

Test codes are another parameter of PCD analyses (e.g. HbA1c testing) but these tend to be limited to a few dozen codes and search strategies are much less
relevant since the relevant tests are known a-priori.

When opening csv files, do not double-click to open in MS Excel because codes will not be imported as strings and for example 2326.00 would be imported as 2326. Instead,
use the import option and make sure you ask for all varibles to be imported as strings

PCD clinical and product files can be Stata or text files

A tricky issue is the names of the variables of interest in the lookup files. The command is compatible with variable names in CPRD Gold and older CPRD versions. Users
of other databases have to rename the respective variables before using pcdsearch (informative error codes will provide the required variable names).

Spaces are not allowed in any of the three input fields but searching for phrases is possible (see below).

Search rules

For fields 1 (Clinical name stubs) and 3 (Product name stubs)

Single word, no special characters: will return all cases that include the stub; e.g. "angin" will return "Ludwig's angina" (Read code J083300) but also "Head-banging" (Read code E273100).

Phrase, underscore used to separate words: will search for an exact phrase; e.g. "ischemic_cardiomyopathy" will search for "ischemic cardiomyopathy", with the same rules as for single word.

Phrase, plus sign used to separate words: will search for all words but not exact phrase; e.g. "alcohol+depend" will return cases where both "alcohol" AND "depend" are found, with the same rules as for single word.

Single word, minus sign at start of word/stub: cases with word/stub to be excluded; e.g. using "splen" and "-hypersplenism" will return cases with "splen" but not any with "hypersplenism" (does not work for with phrases).

Generally words/stubs/phrases need to be inputted as lowercase: the respective fields in the lookup files are turned to lowercase to ensure capitalisation of whole words or letters do no lead to omissions.

If words/stubs/phrases inputted as capitals: will only be searched as capitals to avoid many false positives; e.g. "UTI" will return "suspected UTI" (Read code 1J4..00) but not "Therapeutic enteroscopy" (Read code 7649.11).

For field 2 (Clinical codes)

Codes are searched for exactly as inputted, at the start of the respective field. Hence search for "H33" would return H331.11 (Late onset asthma) but not 8H33.00 (Day hospital care).

Example

Using globals to define directories and files:

. global pcdsourcepath "T:\Evan\GPRD\GPRD\Data\"

. global pcdoutputpath "P:\Evan\GPRD\Mental Health\paper methods\pcdsearch\"

. global pcdcodefilenm "read_oxmis_20081117.dta"

. global pcdprodfilenm "products_20081121.dta"

. pcdsearch asthma.xlsx

Using options to define directories and files:

. pcdsearch asthma.csv, pcddir("R:\CPRD2014\Lookups\") filedir("P:\Evan\GPRD\Mental Health\paper methods\pcdsearch\") pcdcodefnm("medical.txt") pcdprodfnm("product.txt")

Authors

Evangelos Kontopantelis, Centre for Health Informatics, Institute of Population Health, University of Manchester, e.kontopantelis@manchester.ac.uk

Please cite as

Kontopantelis E. pcdsearch: A string and code search programme to extract code lists from primary care databases.

Described in

Olier I., Springate D., Reeves D., Ashcroft D., Doran T., Reilly S. and Kontopantelis E. Modelling conditions in a Primary Care Database:
an application to Severe Mental Illness with the Clinical Practice Research Datalink.

Also see

help for ipdpower, repsample