Skip to content

Commit

Permalink
Merge pull request #30 from OHDSI/unit_tests_optum_clinformatics
Browse files Browse the repository at this point in the history
add scripts optum clinformatics
  • Loading branch information
bradanton authored Dec 4, 2023
2 parents 2070ecd + 3a787ee commit e6535f1
Show file tree
Hide file tree
Showing 30 changed files with 31,654 additions and 14,898 deletions.
12 changes: 6 additions & 6 deletions docs/IBM_CCAE_MDCR/Test Cases/code to run.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ translatedSql <- translate(insertSql, connectionDetails$dbms)
executeSql(conn, translatedSql)

if(truvenType != "MDCD" ){
#YOU NEED A COPY OF GEOLOC IN YOUR RAW
executeSql(conn, paste0("TRUNCATE TABLE ",nativeDatabaseSchema,".GEOLOC; INSERT INTO ",nativeDatabaseSchema,
".GEOLOC (EGEOLOC, EGEOLOC_Description, STATE) VALUES (11, 'New Jersey', 'NJ'); INSERT INTO ",
nativeDatabaseSchema,
".GEOLOC (EGEOLOC, EGEOLOC_Description, STATE) VALUES (38, 'Virginia', 'VA')"))
#YOU NEED A COPY OF GEOLOC IN YOUR RAW
executeSql(conn, paste0("TRUNCATE TABLE ",nativeDatabaseSchema,".GEOLOC; INSERT INTO ",nativeDatabaseSchema,
".GEOLOC (EGEOLOC, EGEOLOC_Description, STATE) VALUES (11, 'New Jersey', 'NJ'); INSERT INTO ",
nativeDatabaseSchema,
".GEOLOC (EGEOLOC, EGEOLOC_Description, STATE) VALUES (38, 'Virginia', 'VA')"))
}

#IF TESTING CCAE YOU NEED A COPY OF HRA_QUESTON_REF, HRA_VARIABLE_REF IN YOUR RAW
if (truvenType == "CCAE" ){
executeSql(conn, paste0("TRUNCATE TABLE ",nativeDatabaseSchema,".HRA_VARIABLE_REF;
Expand Down
5 changes: 4 additions & 1 deletion docs/Optum Clinformatics/Test Cases/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ src/*.o
src/*.so
src/*.dll
/Debug
standalone/build/*
standalone/build/*

#VSCode files
.vscode/
11 changes: 6 additions & 5 deletions docs/Optum Clinformatics/Test Cases/R/CareSiteTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@ createCareSiteTests <- function()
provider <- createProvider()
declareTest("CARE_SITE - Creates a CARE_SITE entry from a record found in native provider table where prov_type is NULL.", #PASS V2.0.0.19
id = provider$provider_id)
add_provider(prov_unique = provider$provid, prov_type = NULL)
add_provider(prov_unique = provider$provid, prov_type = NULL, grp_practice = NULL, hosp_affil = NULL)
expect_care_site(care_site_id = provider$provider_id, care_site_source_value = provider$provider_id, place_of_service_concept_id = 0)


provider <- createProvider()
declareTest("CARE_SITE - Creates a CARE_SITE entry from a record found in native provider table where prov_type = 2.", #PASS V2.0.0.19
id = provider$provider_id)
add_provider(prov_unique = provider$provid, prov_type = 2)
add_provider(prov_unique = provider$provid, prov_type = 2, grp_practice = NULL, hosp_affil = NULL)
expect_care_site(care_site_id = provider$provider_id, care_site_source_value = provider$provider_id, place_of_service_concept_id = 8717)

provider <- createProvider()
declareTest("CARE_SITE - Creates a CARE_SITE entry from a record found in native provider table where prov_type = 3.", #PASS V2.0.0.19
id = provider$provider_id)
add_provider(prov_unique = provider$provid, prov_type = 3)
add_provider(prov_unique = provider$provid, prov_type = 3, grp_practice = NULL, hosp_affil = NULL)
expect_care_site(care_site_id = provider$provider_id, care_site_source_value = provider$provider_id, place_of_service_concept_id = 38004693)

provider <- createProvider()
declareTest("CARE_SITE - Creates a CARE_SITE entry from a record found in native provider table where prov_type = 4.", #PASS V2.0.0.19
id = provider$provider_id)
add_provider(prov_unique = provider$provid, prov_type = 4)
add_provider(prov_unique = provider$provid, prov_type = 4, grp_practice = NULL, hosp_affil = NULL)
expect_care_site(care_site_id = provider$provider_id, care_site_source_value = provider$provider_id, place_of_service_concept_id = 0)


patient <- createPatient()
provider <- createProvider()
claim <- createClaim()
declareTest("CARE_SITE - Creates a CARE_SITE entry from an Rx_claims record", id = provider$provider_id) #PASS V2.0.0.19
add_member_continuous_enrollment(patid = patient$patid, eligeff = '2000-05-01', eligend = '2009-12-31', gdr_cd = 'F', yrdob = 1988)
add_member_continuous_enrollment(patid = patient$patid, eligeff = '2000-05-01', eligend = '2009-12-31', gdr_cd = 'F', yrdob = 1988, ethnicity = NULL)
add_member_enrollment(patid = patient$patid, eligeff = '2000-05-01', eligend = '2009-12-31')
add_rx_claims(patid = patient$patid, pat_planid = patient$patid, fill_dt = '2001-01-01', clmid = claim$clmid, pharm = provider$provid)
expect_care_site(care_site_id = provider$provider_id, care_site_source_value = provider$provider_id, place_of_service_concept_id = 38004340)

Expand Down
2 changes: 2 additions & 0 deletions docs/Optum Clinformatics/Test Cases/R/ConditionEraTests.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

createConditionEraTests <- function()
{
testDiag <- '7061'
Expand All @@ -8,6 +9,7 @@ createConditionEraTests <- function()
id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')

claim <- createClaim()
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2013-07-01',
Expand Down
34 changes: 21 additions & 13 deletions docs/Optum Clinformatics/Test Cases/R/ConditionOccurrenceTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,36 @@ createConditionOccurrenceTests <- function()
declareTest("CONDITION_OCCURRENCE - Patient has 1 record in med_diagnosis with diag in position 1", id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', loc_cd = '2',
lst_dt = '2013-07-01', pat_planid = patient$patid, patid = patient$patid,
fst_dt = '2013-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "9", diag = testDiag, clmid = claim$clmid,
diag_position = '01', poa = 'Y', fst_dt = '2013-07-01', loc_cd = '2')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = testConditionConceptId,
condition_type_concept_id = 44786627, condition_status_concept_id = 46236988)
condition_type_concept_id = 32810, condition_status_concept_id = 32901)

patient <- createPatient()
claim <- createClaim()
declareTest("CONDITION_OCCURRENCE - Patient has 1 record in med_diagnosis with diag in position 4", id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', loc_cd = '2',
lst_dt = '2013-07-01', pat_planid = patient$patid, patid = patient$patid,
fst_dt = '2013-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "9", diag = testDiag, clmid = claim$clmid,
diag_position = '04', fst_dt = '2013-07-01', loc_cd = '2')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = testConditionConceptId,
condition_type_concept_id = 44786629)
condition_type_concept_id = 32810)


patient <- createPatient()
claim <- createClaim()
declareTest("CONDITION_OCCURRENCE - Patient has medical records which have some valid and invalid formatted DIAG codes.", id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2013-07-01', loc_cd = '2',
pat_planid = patient$person_id, patid = patient$person_id, fst_dt = '2013-07-01',
prov = '111111', provcat = '5678')
Expand All @@ -50,6 +53,7 @@ createConditionOccurrenceTests <- function()
declareTest("CONDITION_OCCURRENCE - Patient has a series of 3 inpatient visits with same dates and diagnoses in separate records.", id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2013-07-01', rvnu_cd = '0100', pos = '21', loc_cd = '2',
pat_planid = patient$patid, patid = patient$patid, fst_dt = '2013-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "9", diag = testDiag,
Expand All @@ -71,6 +75,7 @@ createConditionOccurrenceTests <- function()
declareTest("CONDITION_OCCURRENCE - Creates two Condition Occurrences from a single Medical row that specifies an ICD9 code that has multiple SNOMED mappings.", id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2013-07-01', loc_cd = '2',
pat_planid = patient$patid, patid = patient$patid, fst_dt = '2013-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "9", diag = '24910',
Expand All @@ -85,6 +90,7 @@ createConditionOccurrenceTests <- function()
declareTest("CONDITION_OCCURRENCE - Tests ICD10 CM vs International", id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2013-07-01', loc_cd = '2',
pat_planid = patient$patid, patid = patient$patid, fst_dt = '2013-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "10", diag = 'Z731',
Expand All @@ -93,30 +99,32 @@ createConditionOccurrenceTests <- function()
expect_no_condition_occurrence(person_id = patient$person_id, condition_source_value = 'Z731', condition_source_concept_id = 45581067)

poaMappings <- data.frame(
sourceValue = c('Y','N','U','W'),
concept = c(46236988, 0, 0, 0), stringsAsFactors = FALSE
rawValue = c('Y','N','U','W'),
sourceValue = c('Y;01','N;01','U;01','W;01'),
concept = c(32901, 32902, 32902, 32902), stringsAsFactors = FALSE
)

patient <- createPatient()
claim <- createClaim()
declareTest("Creates a record that occurs in the future. Expectation is that it will be deleted.", source_pid = patient$patid, cdm_pid = patient$person_id)
add_member_detail(aso = 'N', bus = 'COM', cdhp = 3, eligeff = '2011-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, pat_planid = patient$patid, product = 'HMO', yrdob = 1979)
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2099-07-01',
pat_planid = patient$patid, patid = patient$patid, fst_dt = '2099-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "9", diag = '24910',
clmid = claim$clmid, diag_position = 1)
expect_no_condition_occurrence(person_id = patient$person_id, condition_source_value = '24910', condition_concept_id = 443727)
#declareTest("Creates a record that occurs in the future. Expectation is that it will be deleted.", source_pid = patient$patid, cdm_pid = patient$person_id)
#add_member_detail(aso = 'N', bus = 'COM', cdhp = 3, eligeff = '2011-05-01', eligend = '2013-10-31',
# gdr_cd = 'F', patid = patient$patid, pat_planid = patient$patid, product = 'HMO', yrdob = 1979)
#add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2099-07-01',
# pat_planid = patient$patid, patid = patient$patid, fst_dt = '2099-07-01', prov = '111111', provcat = '5678')
#add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "9", diag = '24910',
# clmid = claim$clmid, diag_position = 1)
#expect_no_condition_occurrence(person_id = patient$person_id, condition_source_value = '24910', condition_concept_id = 443727)

for (i in 1:nrow(poaMappings)) {
patient <- createPatient()
claim <- createClaim()
declareTest(sprintf("Tests POA = %s", poaMappings[i,]$sourceValue), id = patient$person_id)
add_member_continuous_enrollment(eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, yrdob = 1969)
add_member_enrollment(patid = patient$patid, eligeff = '2010-05-01', eligend = '2013-10-31')
add_medical_claims(clmid = claim$clmid, clmseq = '001', lst_dt = '2013-07-01', loc_cd = '2',
pat_planid = patient$patid, patid = patient$patid, fst_dt = '2013-07-01', prov = '111111', provcat = '5678')
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "10", diag = 'Z731', poa = poaMappings[i,]$sourceValue,
add_med_diagnosis(patid = patient$patid, pat_planid = patient$patid, icd_flag = "10", diag = 'Z731', poa = poaMappings[i,]$rawValue,
clmid = claim$clmid, diag_position = '01', loc_cd = '2', fst_dt = '2013-07-01')
expect_condition_occurrence(person_id = patient$person_id,
condition_status_source_value = poaMappings[i,]$sourceValue,
Expand Down
4 changes: 2 additions & 2 deletions docs/Optum Clinformatics/Test Cases/R/CostTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ createCostTests <- function()
# expect_cost(cost_domain_id = "Visit", cost_type_concept_id = 0, currency_concept_id = 44818668,
# total_charge = 200, paid_by_patient = 175, paid_patient_copay = 10, paid_patient_coinsurance = 100,
# paid_patient_deductible = 75, amount_allowed = 90)



patient <- createPatient()
claim <- createClaim()
declareTest("Patient has drug cost", source_pid = patient$patid, cdm_pid = patient$person_id)
Expand All @@ -30,6 +29,7 @@ createCostTests <- function()
declareTest("Patient has procedure cost", source_pid = patient$patid, cdm_pid = patient$person_id)
add_member_detail(aso = 'N', bus = 'COM', cdhp = 3, eligeff = '2010-05-01', eligend = '2013-10-31',
gdr_cd = 'F', patid = patient$patid, pat_planid = patient$patid, product = 'HMO', yrdob = 1969)

add_medical_claims(clmid = claim$clmid, clmseq = '001', proc_cd = '92928', lst_dt = '2013-07-01',
pat_planid = patient$patid, patid = patient$patid, fst_dt = '2013-07-01', prov = '111111', provcat = '5678',
charge = 200, coins = 100, deduct = 75, copay = 10, std_cost = 90)
Expand Down
Loading

0 comments on commit e6535f1

Please sign in to comment.