Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: ✨ Initial draft of functions to extract osdc population #71

Merged
merged 58 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4b228bd
docs: :sparkles: init overview of functions to create osdc population
signekb Mar 17, 2024
0f6856d
docs: alternative visualisation of functions used for extracting diab…
signekb Mar 17, 2024
abdb477
docs: flow chart expanding on exclusion based on pregnancy window
signekb Mar 17, 2024
1593294
Merge branch 'main' into docs/general-functionality-flow
signekb Mar 17, 2024
7d24d9c
docs: simplify functionality flow of d population to only include fun…
signekb Mar 22, 2024
2969292
docs: :sparkles: initialise functionality flow post
signekb Mar 22, 2024
d1dea76
docs: :art: update overview section w. hyperlinks
signekb Apr 3, 2024
0237ba1
docs: :lipstick: simplify and add colours to inclusion and exclusion …
signekb Apr 3, 2024
287a3d9
docs: update extracting the diabetes population section
signekb Apr 3, 2024
2de0d12
docs: init hba1c tests section
signekb Apr 3, 2024
ffa2dc2
docs: init diagnosis section
signekb Apr 3, 2024
b2a67e6
docs: init podiatrist services section
signekb Apr 3, 2024
128ce5c
docs: init gld purchases section
signekb Apr 3, 2024
2649919
docs: init excl events during pregnancy windows section
signekb Apr 3, 2024
c241be2
docs: init gld drugts for weight loss section
signekb Apr 3, 2024
ed742b7
docs: init metformin purchases for women below 40 section
signekb Apr 3, 2024
700efaf
docs: init extract diagnosis classification date section
signekb Apr 3, 2024
6fcd10a
style: remove old comment and white spaces
signekb Apr 3, 2024
7443a70
Merge branch 'main' into docs/functionality-flow-diabetes-population
signekb Apr 3, 2024
46cb5ef
docs: :fire: remove old/irrelevant figures
signekb Apr 3, 2024
ca809c2
fix: remove all mentions of "before index date" since these filters a…
signekb Apr 12, 2024
2d02224
fix: typo
signekb Apr 12, 2024
23268cf
docs: add that gld purchases are only from 1997 and onwards
signekb Apr 12, 2024
445a118
docs: add TODO note to remember to update whether function will be re…
signekb Apr 12, 2024
56cc88f
docs: remove comment on adding arguments to functions
signekb Apr 12, 2024
505ac73
Merge branch 'main' into docs/functionality-flow-diabetes-population
signekb Apr 12, 2024
9b62a7d
style: :lipstick: format text
signekb Apr 17, 2024
4d222cd
fix: minor text edits and change "classification date" to "inclusion …
signekb Apr 17, 2024
0807c62
docs: add the notion of "raw" vs "stable" inclusion dates to text and…
signekb Apr 17, 2024
2c7ab62
style: format text
signekb Apr 17, 2024
5df493d
docs: :zap: add english translations of register names
signekb Apr 25, 2024
5000d85
Merged origin/main into docs/functionality-flow-diabetes-population
lwjohnst86 Apr 26, 2024
f52b394
docs: apply suggestions from review
lwjohnst86 Apr 26, 2024
9603f76
docs: remove redundant information and link instead to the design doc
lwjohnst86 Apr 26, 2024
221a637
Merge branch 'docs/functionality-flow-diabetes-population' of https:/…
lwjohnst86 Apr 26, 2024
2d6181d
docs: simplify the headers
lwjohnst86 Apr 26, 2024
ac9bf8a
docs: use `()` to indicate object is function, small renaming of func…
lwjohnst86 Apr 26, 2024
024e758
chore: :wrench: set tabsize to 2 for R and qmd files
lwjohnst86 Apr 27, 2024
6fcbaf1
build: :bug: the newest version of PlantUML has an error with buildin…
lwjohnst86 Apr 27, 2024
084485c
docs: :memo: update puml file to use flowchart instead and to include…
lwjohnst86 Apr 27, 2024
aaccf54
docs: :memo: include some guidelines for writing functions
lwjohnst86 Apr 27, 2024
d650c22
docs: :memo: revise function flow doc to match flowchart
lwjohnst86 Apr 27, 2024
49a6610
chore: :truck: rename to function-flow
lwjohnst86 Apr 27, 2024
67029ca
chore: :memo: regenerate puml images
lwjohnst86 Apr 27, 2024
ded4c3d
docs: forgot to change this name
lwjohnst86 Apr 27, 2024
109bbfb
Merged origin/main into docs/functionality-flow-diabetes-population
lwjohnst86 Apr 27, 2024
fee94d4
docs: apply suggestions from review
lwjohnst86 May 2, 2024
30a7881
docs: :art: add introduction section
signekb May 2, 2024
76e2e7d
docs: :art: collect initial and final diagnosis date in one function
signekb May 2, 2024
4614171
Update vignettes/function-flow.Rmd
signekb May 2, 2024
3896ee3
docs: :art: format Rmd
signekb May 2, 2024
baf89c7
docs: add todo item on adding which register get_potential_pcos relie…
signekb May 2, 2024
dc5d771
fix: add "_status" to the name of the "classify_diabetes" function
signekb May 2, 2024
3b7fcd0
docs: :memo: add`_join` helper functions to naming
signekb May 2, 2024
902ef41
docs: update the function flow with the join of lpr2 and 3 data sources
signekb May 2, 2024
6f619dd
docs: remove backticks from package name
signekb May 2, 2024
394f60e
Apply suggestions from code review
signekb May 2, 2024
52535e9
docs: update png based on review feedback
signekb May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions vignettes/functionality-flow.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
title: "Functionality Flow"
output: rmarkdown::html_vignette
bibliography: references.bib
csl: vancouver.csl
vignette: >
%\VignetteIndexEntry{Functionality Flow}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(dplyr)
```

## Overview

The OSDC algorithm - and thereby, the `osdc` package - contains two main
components:

- [Extracting the diabetes population](#extracting-diabetes-population)
- [Classifying the diabetes type (type 1 and type2)](#classifying-diabetes-type)

In the following sections, we will go through each of these components
and the functions they contain.

## Extracting the diabetes population {#extracting-diabetes-population}
lwjohnst86 marked this conversation as resolved.
Show resolved Hide resolved

This component extracts the diabetes population based on the following
five data sources (Danish names in parantheses):

- The Register of Laboratory Results for Research, *RLRR*
(Laboratoriedatabasens Forskertabel)
- The Danish National Patient Registry, *DNPR* (Landspatient
Registeret, *LPR*)
- (Lægemiddelsdatabasen)
- (CPR-registerets befolkningstabel, *BEF*)
- The Health Service Register (Sygesikringsregisteret)

<!-- TODO: Add English translations for Lægemiddelsdatabasen and BEF -->

This component will have one user-facing function:
`extract_diabetes_population`. This function takes the data sources and
an `index_date` (i.e., the day of the wanted classification) as
signekb marked this conversation as resolved.
Show resolved Hide resolved
arguments.

As described in `vignette("design")`, inclusion date is the date of the
second inclusion criteria. Inclusion events include:

<!-- TODO: Add hyperlink to vignette(design) -->

- HbA1c measurements of ≥48 mmol/mol
- Hospital diagnoses of diabetes
- Diabetes-specific services received at podiatrists
- Purchase of glucose-lowering drugs (GLD)

Note that HbA1c tests and GLD purchases during pregnancies are excluded,
as are glucose-lowering brand drugs for weight loss and metformin
purchases for women below age 40. See section \[Exclusion: HbA1c tests
and GLD purchases during estimated pregnancy
windows\](#exclusion-pregnancy-windows) for how pregnancy windows are
estimated.

This results in the functionality flow for extracting the diabetes
population seen below. All functions take a `data.frame` as input and
outputs a `data.frame`.

![Flow of functions for extracting a diabetes population using the osdc
package. The dark grey box denotes the user-facing function, while the
remaining boxes are internal functions. Green and red boxes represent
filtering functions (inclusion and exclusion events,
respectively).](images/diabetes-population-functions.png)

<!-- Q: How are we feeling about the colours? All internal functions could also just be light grey -->

<!-- Q: Generally, Do we want to include arguments in inclusion and exclusion functions so a (technically inclined) user will be able to alter the algorithm for their needs? E.g., age could be an argument in `exclude_potential_pcos` -->

signekb marked this conversation as resolved.
Show resolved Hide resolved
### Inclusion event: HbA1c tests above 48 mmol/mol

The function `include_hba1c_tests_over_48_mmol_per_mol` uses RLRR as
data source to extract all events of tests above 48 mmol/mol before the
index date.
signekb marked this conversation as resolved.
Show resolved Hide resolved

<!-- TODO: Add details on how this filtering should be done -->

<!-- TODO: Is it really *all* or is there a time window before the index date we're extracting from? -->

### Inclusion event: Hospital diagnosis of diabetes

The function `include_diabetes_diagnoses` uses the hospital contacts
from DNPR to include all dates of diabetes diagnoses before the index
date. Diabetes diagnoses from both ICD 8 and ICD 10 are included.

This function contains two helper functions:

- `extract_diabetes_diagnoses_icd_10`
- `extract_diabetes_diagnoses_icd_8`

<!-- TODO: Add details on how this filtering should be done, e.g., diagnosis codes -->

<!-- TODO: Which specific ICD 8 and 10 codes are included? -->

<!-- TODO: Is it really *all* or is there a time window before the index date we're extracting from? -->

### Inclusion event: Diabetes-specific podiatrist services

The function `include_diabetes_specific_podiatrist_services` uses the
Health Service Register to extract the dates of all diabetes-specific
podiatrist services before the index date.

<!-- TODO: Add details on how this filtering should be done -->

<!-- TODO: Is it really *all* or is there a time window before the index date we're extracting from? -->

### Inclusion event: GLD purchases

The function `include_gld_purchases` uses Lægemiddelsdatabasen to
extract the dates of all GLD purchases before the index date.

<!-- TODO: Add English translation of data source -->

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be easily done with the variable_description dataframe. Which I will add shortly.

<!-- TODO: Add details on how this filtering should be done -->

<!-- TODO: Is it really *all* or is there a time window before the index date we're extracting from? -->

signekb marked this conversation as resolved.
Show resolved Hide resolved
### Exclusion: HbA1c tests and GLD purchases during estimated pregnancy windows {#exclusion-pregnancy-windows}

The function `exclude_events_during_pregnancy_windows` uses diagnoses
from DNPR as a data source and is used to exclude both HbA1c tests and
GLD purchases during estimated pregnancy windows.

Under the hood, this relies on the function
`extract_pregnancy_index_dates` and contains the following three helper
functions:

- `calculate_pregnancy_index_date_for_mc_visits_wo_end_date` (this
might be removed with the inclusion of )
- `extract_pregnancy_end_dates`
- `extract_maternal_care_visit_dates_without_end_date`

`calculate_pregnancy_index_date_for_mc_visits_wo_end_date` might be
removed with the inclusion of the birth register.
signekb marked this conversation as resolved.
Show resolved Hide resolved

`extract_pregnancy_end_dates` extracts maternal care visits with an end
date and exclude visits between 40 weeks before end date to 12 weeks
after end date.

`extract_maternal_care_visit_dates_without_end_date` uses the output
from `extract_pregnancy_end_dates` which identifies maternal care visits
*with* end dates to derive maternal care visits *without* end dates.
below.
<!-- TOOD: What is done with the mc visits without end dates then? -->

<!-- TODO: Add details on how this filtering should be done -->

### Exclusion: Glucose-lowering brand drugs for weight loss

The function `exclude_weight_loss_drugs` uses \*\* as a data source and
excludes **which brands**?

<!-- TODO: Add details on how this filtering should be done -->

### Exclusion: Metformin purchases for women below age 40

The function `exclude_potential_pcos` uses BEF to exclude all purchases
of metformin by women below age 40 (i.e., <= 39 years old) at the date of
purchase.

This function contains two helper functions:

- `exclude_women`
- `exclude_age_40_or_younger`

<!-- TODO: Add English translation of BEF -->

<!-- TODO: Add details on how this filtering should be done -->

### Extract diagnosis classification date

Finally, the inclusion events from each inclusion criteria are joined in
the function `extract_classification_dates`. For each individual with
inclusion events, the date of the *second* event is extracted as the
classification date, i.e., the date the OSDC algorithm defines as the
diagnosis date.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions vignettes/images/diabetes-population-functions.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@startuml diabetes-population-functions

#darkgrey: Extract_diabetes_population;

switch (Extract dates of inclusion events)
case ( HbA1c tests)
#lightgreen:include_hba1c_tests_over_48_mmol_per_mol;
#pink:exclude_events_during_pregnancy_windows;

case ( Hospital diabetes\n diagnosis)
#lightgreen:include_diabetes_diagnoses;

case ( Diabetes-specific\n podiatrist services)
#lightgreen:include_diabetes_specific_podiatrist_services;

case ( GLD purchases)
#lightgreen:include_gld_purchases;
#pink:exclude_events_during_pregnancy_windows;
#pink:exclude_potential_pcos;
#pink:exclude_purchases_of_weight_loss_drugs;
endswitch

:extract_classification_dates;

@enduml
Loading