-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from OHDSI/unit_tests_PREMIER
fix unit test PREMIER
- Loading branch information
Showing
31 changed files
with
16,033 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.Rproj.user | ||
.Rhistory | ||
*.RData | ||
.Ruserdata | ||
*errorReport.txt | ||
*.Rprofile | ||
/inst/sql/sql_server/insert.sql | ||
/inst/sql/sql_server/test.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Package: PremierTests | ||
Type: Package | ||
Title: Configures Test Cases for Premier | ||
Version: 0.1.0 | ||
Author: Chris Knoll | ||
Maintainer: Chris Knoll <[email protected]> | ||
Description: Executes test case inserts and validates results. | ||
License: None | ||
LazyData: TRUE | ||
Depends: | ||
SqlRender, | ||
DatabaseConnector | ||
Roxygen: list(wrap = TRUE) | ||
RoxygenNote: 6.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(generateInsertSql) | ||
export(generateTestSql) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
|
||
BuildType: Package | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
createConditionOccurrenceTests <- function () { | ||
|
||
|
||
# PATICD_DIAG.ICD_CODE ICD9CM | ||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description="ICD9CM record from PATICD_DIAG to condition_occurrence table", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key, | ||
adm_date = "2005-01-01", | ||
disc_date = "2005-01-01"); | ||
add_patbill(pat_key = visit$pat_key); | ||
add_paticd_diag(pat_key = visit$pat_key, | ||
icd_code = "112.89", | ||
icd_version = 9); | ||
expect_condition_occurrence(person_id = patient$person_id, | ||
visit_occurrence_id = visit$visit_occurrence_id, | ||
condition_concept_id = 433968, | ||
condition_start_date = "2005-01-01", | ||
condition_source_value = '112.89'); | ||
|
||
# PATICD_DIAG.ICD_CODE ICD10CM | ||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description="ICD10CM record from PATICD_DIAG to condition_occurrence table", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key, | ||
adm_date = "2004-03-01", | ||
disc_date = "2004-03-01"); | ||
add_patbill(pat_key = visit$pat_key); | ||
add_paticd_diag(pat_key = visit$pat_key, | ||
icd_code = "M05.421", | ||
icd_version = 10); | ||
expect_condition_occurrence(person_id = patient$person_id, | ||
visit_occurrence_id = visit$visit_occurrence_id, | ||
condition_concept_id = 4116440, | ||
condition_start_date = "2004-03-01", | ||
condition_source_value = "M05.421"); | ||
expect_condition_occurrence(person_id = patient$person_id, | ||
visit_occurrence_id = visit$visit_occurrence_id, | ||
condition_concept_id = 4107913, #map to multiple concepts? | ||
condition_start_date = "2004-03-01", | ||
condition_source_value = "M05.421"); | ||
|
||
#PRI_SEC flag to condition_status_concept_id | ||
pri_sec_vals <- data.frame( | ||
icd_pri_sec = c('A', 'P', 'S'), | ||
concept_id = c('32890', '32902', '32908')); | ||
|
||
for (i in 1:nrow(pri_sec_vals)) | ||
{ | ||
pri_sec_val <- pri_sec_vals[i,] | ||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description=paste0("PATICD_DIAG.ICD_PRI_SEC = ", pri_sec_val$icd_pri_sec, " to CONDITION_STATUS_CONCEPT_ID = ", pri_sec_val$concept_id), | ||
id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key); | ||
add_paticd_diag(pat_key = visit$pat_key, | ||
icd_pri_sec = as.character(pri_sec_val$icd_pri_sec)); | ||
expect_condition_occurrence(person_id = patient$person_id, | ||
visit_occurrence_id = visit$visit_occurrence_id, | ||
condition_status_concept_id = pri_sec_val$concept_id, | ||
condition_status_source_value = pri_sec_val$icd_pri_sec); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
createCostTests <- function () { | ||
|
||
patient <- createPatient() | ||
visit <- createVisit() | ||
declareTest(description="Cost record from drug_exposure", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key); | ||
add_patbill(pat_key = visit$pat_key, | ||
std_chg_code = 250250038820000, | ||
bill_charges = 500.50, | ||
bill_cost = 300.75); | ||
add_chgmstr(std_chg_code = 250250038820000, | ||
sum_dept_desc = "PHARMACY", | ||
std_dept_desc = "PHARMACY"); | ||
expect_drug_exposure(person_id = patient$person_id, | ||
drug_concept_id = 19042590); | ||
expect_cost(cost_domain_id = "Drug", | ||
total_charge = 500.50, | ||
total_cost = 300.75, | ||
revenue_code_concept_id = 38003147, | ||
revenue_code_source_value = "PHARMACY / PHARMACY"); | ||
|
||
|
||
patient <- createPatient() | ||
visit <- createVisit() | ||
declareTest(description="Cost record from procedure_occurrence", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key); | ||
add_patbill(pat_key = visit$pat_key, | ||
std_chg_code = 33840, | ||
bill_charges = 29374.99, | ||
bill_cost = 13572.76); | ||
add_chgmstr(std_chg_code = 33840, | ||
sum_dept_desc = "OR", | ||
std_dept_desc = "SURGERY"); | ||
expect_procedure_occurrence(person_id = patient$person_id, | ||
procedure_concept_id = 2107402); | ||
expect_cost(cost_domain_id = "Procedure", | ||
total_charge = 29374.99, | ||
total_cost = 13572.76, | ||
revenue_code_concept_id = 38003208, | ||
revenue_code_source_value = "OR / SURGERY"); | ||
|
||
|
||
patient <- createPatient() | ||
visit <- createVisit() | ||
declareTest(description="Cost record from device_exposure", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key); | ||
add_patbill(pat_key = visit$pat_key, | ||
std_chg_code = 270275000120000, | ||
bill_charges = 499.99, | ||
bill_cost = 99.99); | ||
add_chgmstr(std_chg_code = 270275000120000, | ||
sum_dept_desc = "SUPPLY", | ||
std_dept_desc = "CENTRAL SUPPLY"); | ||
expect_device_exposure(person_id = patient$person_id, | ||
device_concept_id = 4236068); | ||
expect_cost(cost_domain_id = "Device", | ||
total_charge = 499.99, | ||
total_cost = 99.99, | ||
revenue_code_concept_id = 38003163, | ||
revenue_code_source_value = "SUPPLY / CENTRAL SUPPLY"); | ||
|
||
|
||
patient <- createPatient() | ||
visit <- createVisit() | ||
declareTest(description="Cost record from observation", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key); | ||
add_patbill(pat_key = visit$pat_key, | ||
std_chg_code = 110214000620000, | ||
bill_charges = 2347.77, | ||
bill_cost = 2000.00); | ||
add_chgmstr(std_chg_code = 110214000620000, | ||
sum_dept_desc = "OTHER", | ||
std_dept_desc = "DIALYSIS"); | ||
expect_observation(person_id = patient$person_id, | ||
observation_concept_id = 4227255); | ||
expect_cost(cost_domain_id = "Observation", | ||
total_charge = 2347.77, | ||
total_cost = 2000.00, | ||
revenue_code_concept_id = 38003458, | ||
revenue_code_source_value = "OTHER / DIALYSIS"); | ||
|
||
|
||
patient <- createPatient() | ||
visit <- createVisit() | ||
declareTest(description="Cost record from measurement", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key); | ||
add_patbill(pat_key = visit$pat_key, | ||
std_chg_code = 85013, | ||
bill_charges = 79.99, | ||
bill_cost = 19.50); | ||
add_chgmstr(std_chg_code = 85013, | ||
sum_dept_desc = "LAB", | ||
std_dept_desc = "LABORATORY"); | ||
expect_measurement(person_id = patient$person_id, | ||
measurement_concept_id = 4016241); | ||
expect_cost(cost_domain_id = "Measurement", | ||
total_charge = 79.99, | ||
total_cost = 19.50, | ||
revenue_code_concept_id = 38003172, | ||
revenue_code_source_value = "LAB / LABORATORY"); | ||
|
||
|
||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description="MS_DRG record (1 digit) to cost table", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key, | ||
adm_date = "2005-01-01", | ||
disc_date = "2005-01-01", | ||
ms_drg = 1); | ||
add_patbill(pat_key = visit$pat_key); | ||
expect_count_cost(drg_concept_id = 38000887, #drg=001 | ||
drg_source_value = "001", | ||
rowCount = 1); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
createDeathTests <- function () | ||
{ | ||
|
||
# note death.death_date = visit_occurrence.visit_end_date | ||
|
||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description = "Death from PAT.DISC_STATUS without PATICD.ICD_CODE death codes", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key, | ||
adm_date = "2010-10-01", | ||
disc_date = "2010-10-04", | ||
disc_status = 20); | ||
add_patbill(pat_key = visit$pat_key) | ||
expect_death(person_id = patient$person_id, | ||
death_type_concept_id = 32812, | ||
death_date = '2010-10-04'); | ||
|
||
|
||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description = "Death from PAT.DISC_STATUS with PATICD.ICD_CODE death code, use DISC_STATUS", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key, | ||
adm_date = "2010-10-01", | ||
disc_date = "2010-10-04", | ||
disc_status = 20); | ||
add_patbill(pat_key = visit$pat_key) | ||
add_paticd_diag(pat_key = visit$pat_key, | ||
icd_version = 10, | ||
icd_code = "G93.82") | ||
expect_death(person_id = patient$person_id, | ||
death_type_concept_id = 32812, | ||
death_date = '2010-10-04'); | ||
|
||
|
||
patient <- createPatient(); | ||
visit <- createVisit(); | ||
declareTest(description = "Death PATICD.ICD_CODE death code", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit$pat_key, | ||
adm_date = "2010-10-01", | ||
disc_date = "2010-10-04", | ||
disc_status = 99); | ||
add_patbill(pat_key = visit$pat_key); | ||
add_paticd_diag(pat_key = visit$pat_key, | ||
icd_version = 10, | ||
icd_code = "G93.82"); | ||
expect_death(person_id = patient$person_id, | ||
death_type_concept_id = 32875, | ||
death_date = '2010-10-04'); | ||
|
||
|
||
patient <- createPatient(); | ||
visit1 <- createVisit(); | ||
visit2 <- createVisit(); | ||
declareTest(description = "No records populated >32 days after death", id = patient$person_id); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit1$pat_key, | ||
adm_date = "2010-10-01", | ||
disc_date = "2010-10-04", | ||
disc_status = 20); | ||
add_patbill(pat_key = visit1$pat_key); | ||
add_pat(medrec_key = patient$medrec_key, | ||
pat_key = visit2$pat_key, | ||
adm_date = "2011-01-01", | ||
disc_date = "2011-01-01", | ||
disc_status = 99); | ||
add_patbill(pat_key = visit2$pat_key); | ||
expect_death(person_id = patient$person_id, | ||
death_type_concept_id = 32812, | ||
death_date = '2010-10-04'); | ||
expect_no_visit_occurrence(person_id = patient$person_id, | ||
visit_occurrence_id = visit2$visit_occurrence_id, | ||
visit_start_date = '2011-01-01', | ||
visit_end_date = '2011-01-01') | ||
|
||
} | ||
|
Oops, something went wrong.