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

Minor fixes to fake data #87

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 2 additions & 2 deletions data-raw/simulate-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ create_padded_integer <- function(n, length) {
create_fake_npu <- function(n) {
stringr::str_c(
"NPU",
create_padded_integer(n, 8)
create_padded_integer(n, 5)
)
}

Expand All @@ -105,7 +105,7 @@ create_fake_drug_name <- function(atc) {
}

to_wwyy <- function(x) {
format(lubridate::as_date(x), format = "%W%y")
paste0(lubridate::isoweek(lubridate::as_date(x)), stringr::str_sub(lubridate::isoyear(lubridate::as_date(x)), -2))
}

to_yyyymmdd <- function(x) {
Expand Down
78 changes: 39 additions & 39 deletions data-raw/simulation-definitions.csv
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
register_abbrev,variable_name,data_type,format,generator,explanation_of_values,comments
bef,koen,integer,binary,"draw_binary(0.5, N = N) + 1","2 is woman, 1 is man",
bef,pnr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,
bef,foed_dato,date,YYYYMMDD,"to_yyyymmdd(create_fake_date(N, from = ""1900-01-01""))",,
lmdb,volume,double,standard,"runif(N, 1, 10)",,
lmdb,pnr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,
lmdb,eksd,date,YYYYMMDD,"to_yyyymmdd(create_fake_date(N, from = ""1995-01-01""))",,
lmdb,atc,string,7 digits,create_fake_atc(N),"""^A10"" is glucose-lowering medications",
lmdb,apk,integer,standard,"runif(N, 1, 10)",,
lmdb,indo,string,blank or 7 digits zero-padded,"create_padded_integer(N, 7)",refer to the KAT classification,"the only used values are ""0000092"", ""0000276"", ""0000781"""
lmdb,name,string,natural language,,,"Need to run create_fake_drug_name() afterwards, since it depends on atc"
lmdb,vnr,string,6 digits zero-padded,"create_padded_integer(N, 6)",,
lpr_adm,c_spec,string,2 digits zero-padded,"create_padded_integer(N, 2)",,c_blok is derived from c_spec
lpr_adm,pnr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,
lpr_adm,recnum,string,18 digits zero-padded,"create_padded_integer(N, 18)",,
lpr_adm,d_inddto,date,YYYYMMDD,to_yyyymmdd(create_fake_date(N)),,
lpr_diag,c_diagtype,string,"1 digit (A, B, H, +)","draw_categorical(N = N, prob = c(0.3, 0.7), category_labels = c('A', 'B'))",,
lpr_diag,recnum,string,18 digits zero-padded,"create_padded_integer(N, 18)",,
lpr_diag,c_diag,string,icd8 or icd10,create_fake_icd(N),"""^249|^250|^DE1[0-4]"" are diabetes codes",
kontakter,cpr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,lpr3 equivalent to pnr
kontakter,dw_ek_kontakt,string,18 digits zero-padded,"create_padded_integer(N, 18)",,lpr3 equivalent to recnum
kontakter,dato_start,date,YYYYMMDD,to_yyyymmdd(create_fake_date(N)),,lpr3 equivalent to inddto
kontakter,hovedspeciale_ans,string,natural language,create_fake_hovedspeciale_ans(N),Is the LPR3 equivalent to c_spec but with different format,need to copy lpr2-lpr3 conversion table from dst
diagnoser,dw_ek_kontakt,string,18 digits zero-padded,"create_padded_integer(N, 18)",,lpr3 equivalent to recnum
diagnoser,diagnosekode,string,icd10,create_fake_icd10(N),"""^DE1[0-4]"" are diabetes codes",
diagnoser,diagnosetype,string,"1 digit (A, B, H, +)","draw_binary(0.3, N = N)","0/A is a primary diagnosis, 1/B is a secondary diagnosis",
diagnoser,senere_afkraeftet,string,Binary natural language,"draw_categorical(N = N, prob = c(0.2, 0.8), category_labels = c('Ja', 'Nej'))",,
sysi,pnr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,
sysi,barnmak,integer,binary,"draw_binary(0.1, N = N)",0 is no,
sysi,speciale,string,5 digits,"create_padded_integer(N, 5)","""^54"" is diabetes-specific podiatrist service",
sysi,honuge,string,"4 digits: WWyy (2 digits week number, 2 digits year)","to_wwyy(create_fake_date(N, from = ""1990-01-01""))",,
sssy,pnr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,
sssy,barnmak,integer,binary,"draw_binary(0.1, N = N)",0 is no,
sssy,speciale,string,5 digits,"create_padded_integer(N, 5)","""^54"" is diabetes-specific podiatrist service",
sssy,honuge,string,"4 digits: WWyy (2 digits week number, 2 digits year)","to_wwyy(create_fake_date(N, from = ""1990-01-01""))",,
lab_forsker,patient_cpr,string,12 digits zero-padded,"create_padded_integer(N, 12)",,
lab_forsker,samplingdate,date,YYYYMMDD,"to_yyyymmdd(create_fake_date(N, from = ""2011-01-01""))",,
lab_forsker,analysiscode,string,8 digit NPU code,create_fake_npu(N),NPU27300 is HbA1c in modern units (IFCC),NPU03835 is HbA1c in old units
lab_forsker,value,double,standard,"runif(N, 1, 180)",,
register_abbrev;variable_name;data_type;format;generator;explanation_of_values;comments
bef;koen;integer;binary;draw_binary(0.5, N = N) + 1;2 is woman, 1 is man;NA
bef;pnr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;NA
bef;foed_dato;date;YYYYMMDD;"to_yyyymmdd(create_fake_date(N, from = ""1900-01-01""))";NA;NA
lmdb;volume;double;standard;runif(N, 1, 10);NA;NA
lmdb;pnr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;NA
lmdb;eksd;date;YYYYMMDD;"to_yyyymmdd(create_fake_date(N, from = ""1995-01-01""))";NA;NA
lmdb;atc;string;7 digits;create_fake_atc(N);"""^A10"" is glucose-lowering medications";NA
lmdb;apk;integer;standard;runif(N, 1, 10);NA;NA
lmdb;indo;string;blank or 7 digits zero-padded;create_padded_integer(N, 7);refer to the KAT classification;"the only used values are ""0000092"", ""0000276"", ""0000781"""
lmdb;name;string;natural language;NA;NA;Need to run create_fake_drug_name() afterwards, since it depends on atc
lmdb;vnr;string;6 digits zero-padded;create_padded_integer(N, 6);NA;NA
lpr_adm;c_spec;string;2 digits zero-padded;create_padded_integer(N, 2);NA;c_blok is derived from c_spec
lpr_adm;pnr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;NA
lpr_adm;recnum;string;18 digits zero-padded;create_padded_integer(N, 18);NA;NA
lpr_adm;d_inddto;date;YYYYMMDD;to_yyyymmdd(create_fake_date(N));NA;NA
lpr_diag;c_diagtype;string;1 digit (A, B, H, +);draw_categorical(N = N, prob = c(0.3, 0.7), category_labels = c('A', 'B'));NA;NA
lpr_diag;recnum;string;18 digits zero-padded;create_padded_integer(N, 18);NA;NA
lpr_diag;c_diag;string;icd8 or icd10;create_fake_icd(N);"""^249|^250|^DE1[0-4]"" are diabetes codes";NA
kontakter;cpr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;lpr3 equivalent to pnr
kontakter;dw_ek_kontakt;string;18 digits zero-padded;create_padded_integer(N, 18);NA;lpr3 equivalent to recnum
kontakter;dato_start;date;YYYYMMDD;to_yyyymmdd(create_fake_date(N));NA;lpr3 equivalent to inddto
kontakter;hovedspeciale_ans;string;natural language;create_fake_hovedspeciale_ans(N);Is the LPR3 equivalent to c_spec but with different format;need to copy lpr2-lpr3 conversion table from dst
diagnoser;dw_ek_kontakt;string;18 digits zero-padded;create_padded_integer(N, 18);NA;lpr3 equivalent to recnum
diagnoser;diagnosekode;string;icd10;create_fake_icd10(N);"""^DE1[0-4]"" are diabetes codes";NA
diagnoser;diagnosetype;string;1 digit (A, B, H, +);draw_categorical(N = N, prob = c(0.3, 0.7), category_labels = c('A', 'B'));0/A is a primary diagnosis, 1/B is a secondary diagnosis;NA
diagnoser;senere_afkraeftet;string;Binary natural language;draw_categorical(N = N, prob = c(0.2, 0.8), category_labels = c('Ja', 'Nej'));NA;NA
sysi;pnr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;NA
sysi;barnmak;integer;binary;draw_binary(0.1, N = N);0 is no;NA
sysi;speciale;string;5 digits;create_padded_integer(N, 5);"""^54"" is diabetes-specific podiatrist service";NA
sysi;honuge;string;4 digits: WWyy (2 digits week number, 2 digits year);"to_wwyy(create_fake_date(N, from = ""1990-01-01""))";NA;NA
sssy;pnr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;NA
sssy;barnmak;integer;binary;draw_binary(0.1, N = N);0 is no;NA
sssy;speciale;string;5 digits;create_padded_integer(N, 5);"""^54"" is diabetes-specific podiatrist service";NA
sssy;honuge;string;4 digits: WWyy (2 digits week number, 2 digits year);"to_wwyy(create_fake_date(N, from = ""1990-01-01""))";NA;NA
lab_forsker;patient_cpr;string;12 digits zero-padded;create_padded_integer(N, 12);NA;NA
lab_forsker;samplingdate;date;YYYYMMDD;"to_yyyymmdd(create_fake_date(N, from = ""2011-01-01""))";NA;NA
lab_forsker;analysiscode;string;8 digit NPU code;create_fake_npu(N);NPU27300 is HbA1c in modern units (IFCC);NPU03835 is HbA1c in old units
lab_forsker;value;double;standard;runif(N, 1, 180);NA;NA
Loading