testdoseconvert: Test the Dose Conversion Program Against a Set of Texts With...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Calls doseconvert on each individual dose string, to extract structured information such as quantity, frequency and units.

Usage

1
2
3
4
5
6
testdoseconvert(text = goldstandard$text, textid = NULL,
    simplify = TRUE, singlewords = NULL, multiwords = NULL,
    patterns = NULL, maxifchoice = TRUE, usebuiltinlookups = FALSE,
    customlookups = NULL, cores = 1,
    noisy = ifelse(length(text) == 1, TRUE, FALSE),
    goldstandard = NULL)

Arguments

text

Dosage strings to be interpreted.

textid

Optional vector of text or numeric identifiers for the dosage strings.

simplify

FALSE if multiple periods with different doses should be returned as separate doses; TRUE if they should be combined into a single dose (default), thus returning one row per original dosage text.

singlewords

A drugdose_singlewords object or file path to the singlewords dictionary. If NULL it is loaded from the package data directory.

multiwords

A drugdose_multiwords object or file path to the multiwords dictionary. If NULL it is loaded from the package data directory.

patterns

A drugdose_patterns object or file path to the patterns dictionary. If NULL it is loaded from the package data directory.

maxifchoice

Whether to return the maximum dose if there is a choice of dose (e.g. 1 or 2 tablets daily). If FALSE, the average is returned.

usebuiltinlookups

Whether to use the lookup table of exact dose strings and their conversion included in the package.

customlookups

A drugdose_lookups object or file path to the a custom lookups table. This may consist of errors that you have found and corrected, for which you would like the algorithm to use the correct interpretation in the future.

cores

Number of cores to use, for multiprocessor machines running R on Linux. The 'parallel' package must be loaded in order to use more than one core.

noisy

TRUE or FALSE - whether to display each text and the results of interpretation to the console. By default, noisy = TRUE if only one text is being analysed.

goldstandard

A data.frame or data.table containing textid and interpreted results (i.e. in the same format as the output) against which the results can be compared. This should have the following columns: words (optional), qty, units, freq, tot, max, time, change, choice, duration, daily_dose

Details

This function can be used to test the interpretation of a single text, or test a number of texts against a gold standard interpretation.

Value

Data.table with the following columns:

textid

text identifier

order

if simplify = TRUE, this column is not included. If simplify = FALSE, there may be multiple result lines per text entry, and this column states the order of the result lines.

outcome

outcome of comparison with gold standard; factor with 3 levels: 'actual', 'intended' or 'correct'. If there is no gold standard, all rows have the outcome 'actual'. If there is a goldstandard and the interpretation is correct, the outcome is 'correct', otherwise there are 2 or rows of output, one with outcome 'actual' and the other 'intended'.

qty

numeric; dose quantity

units

character; dose units

freq

numeric; dose frequency per time period

tot

numeric; total dose per time period

max

factor with 3 levels: max, average, exact

time

numeric; time interval in number of days

change

factor with 4 levels: first, second, nochange, combined. If doses for different time periods combined using simplify = TRUE, change states which dose contributes to the output.

choice

factor with 3 levels: choice, asneeded, nochoice

duration

numeric; duration of prescription

daily_dose

numeric; calculated daily dose

Note

Converted from the original Visual Basic algorithm. Used as part of the testing process for this package.

Author(s)

Anoop Shah

References

Shah AD, Martinez C. An algorithm to derive a numerical daily dose from unstructured text dosage instructions. Pharmacoepidemiol Drug Saf 2006; 15(3): 161-166. doi: 10.1002/pds.1151 http://onlinelibrary.wiley.com/doi/10.1002/pds.1151/

See Also

interpret, doseconvert

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(testset)

results <- as.data.table(testdoseconvert(
    testset$text, goldstandard = testset, noisy = FALSE))
if (all(results$outcome == 'correct')){
    cat('\nAll correct.')
} else {
    cat('\nErrors in analysis:\n')
    print(results[(outcome == 'intended' | outcome == 'actual')][
        order(textid, order, outcome)])
}

CALIBERdrugdose documentation built on May 2, 2019, 6:49 p.m.