Skip to content

Commit

Permalink
Merge pull request #36 from OHDSI/ibms-tests-updates
Browse files Browse the repository at this point in the history
new tests added
  • Loading branch information
bradanton authored Dec 4, 2023
2 parents e6535f1 + ee0b31e commit 4de3ca1
Show file tree
Hide file tree
Showing 25 changed files with 2,304 additions and 122,552 deletions.
21 changes: 18 additions & 3 deletions docs/IBM_CCAE_MDCR/Test Cases/R/ConditionOccurrenceTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,33 @@ createConditionOccurrenceTests <- function () {
# expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_status_concept_id = '32908', condition_start_date = '2012-08-02', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_start_date = '2012-07-01', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_start_date = '2012-08-02', condition_type_concept_id = '32854')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Event date is outside of observation_period, condition_occurrence record created. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid = patient$enrolid, svcdate = '2022-08-02', tsvcdat = '2022-08-02', dx4='57411', dxver='9')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_start_date = '2022-08-02', condition_type_concept_id = '32854')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Condition_occurrence record default end_date is NULL. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid = patient$enrolid, svcdate = '2022-08-03', dx4='57411', dxver='9')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_start_date = '2022-08-03', condition_end_date = NULL)


if (truvenType == "MDCD")
if (tolower(frameworkType) == "mdcd")
{
patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has diagnosis in dx1 in ltc. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_long_term_care(enrolid = patient$enrolid, dx1 = 'v901', dxver = '9', svcdate = '2012-11-05', tsvcdat = '2012-11-10')
add_long_term_care(enrolid = patient$enrolid, dx1 = 'v9001', dxver = '9', svcdate = '2012-11-05', tsvcdat = '2012-11-10')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '46270117', condition_type_concept_id = '38004277')
}

if (truvenType == "CCAE")
if (tolower(frameworkType) == "ccae")
{
patient <- createPatient()
encounter <- createEncounter()
Expand Down
2 changes: 1 addition & 1 deletion docs/IBM_CCAE_MDCR/Test Cases/R/CostTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ createCostTests <- function () {
# event_ID <- lookup_procedure_occurrence(fetchField = "procedure_occurrence_id", person_id = patient$person_id)
# expect_cost(cost_event_id = event_ID , revenue_code_concept_id = 0)
#
# if (Sys.getenv("truvenType") == "MDCD")
# if (Sys.getenv("frameworkType") == "MDCD")
# {
# patient <- createPatient()
# encounter <- createEncounter()
Expand Down
62 changes: 26 additions & 36 deletions docs/IBM_CCAE_MDCR/Test Cases/R/DeathTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ createDeathTests <- function () {

set_defaults_enrollment_detail(mhsacovg = '0')

if (tolower(frameworkType) != "mdcd")
{
patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Date of death visit end date. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2015-12-31', dtstart = '2012-01-01', mhsacovg = 0)
add_inpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-01-06', tsvcdat='2013-01-09')
add_outpatient_services(enrolid = patient$enrolid, year = '2013', svcdate = '2013-01-07',tsvcdat = '2013-01-07', dx1 = '7981', dxver = '9', fachdid = encounter$caseid)
add_facility_header(enrolid=patient$enrolid, svcdate = '2013-01-07', tsvcdat = '2013-01-07', dx9 = '7981', fachdid = encounter$caseid, dxver='9')
expect_death(person_id = patient$person_id, death_date = '2013-01-09')

patient <- createPatient()
encounter <- createEncounter()
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2016-12-31', dtstart = '2012-01-01', mhsacovg = '0')
declareTest(id = patient$person_id, "ICD10 Death and Death Type Correct. Id is PERSON_ID.")
add_inpatient_services(enrolid=patient$enrolid, year = '2016', svcdate = '2016-01-06', tsvcdat='2016-01-09', dxver = '0', dx1='I461')
expect_death(person_id = patient$person_id, death_type_concept_id = '32812')

patient <- createPatient()
encounter <- createEncounter()
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2015-12-31', dtstart = '2012-01-01', mhsacovg = '0')
declareTest(id = patient$person_id, "ICD9 Death and Death Type Correct. Id is PERSON_ID.")
add_inpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-01-06', tsvcdat='2013-01-09', dxver = '9', dx1='798')
expect_death(person_id = patient$person_id, death_type_concept_id = '32812')
}

patient <- createPatient()
encounter <- createEncounter()
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2013-02-01', dtstart = '2012-01-01', mhsacovg = '0')
Expand All @@ -25,40 +51,4 @@ createDeathTests <- function () {
add_outpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-03-12')
expect_no_death(person_id=patient$enrolid)


if (truvenType == "MDCD")
{
patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has icd9 death cord in ltc, death record created. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_long_term_care(enrolid = patient$enrolid, dx1 = '798', dxver = '9', svcdate = '2012-11-02', tsvcdat = '2012-11-22')
expect_no_death(person_id = patient$person_id)
}
else
{
patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Date of death visit end date. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2015-12-31', dtstart = '2012-01-01', mhsacovg = 0)
add_inpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-01-06', tsvcdat='2013-01-09')
add_outpatient_services(enrolid = patient$enrolid, year = '2013', svcdate = '2013-01-07',tsvcdat = '2013-01-07', dx1 = '7981', dxver = '9', fachdid = encounter$caseid)
add_facility_header(enrolid=patient$enrolid, svcdate = '2013-01-07', tsvcdat = '2013-01-07', dx9 = '7981', fachdid = encounter$caseid, dxver='9')
expect_death(person_id = patient$person_id, death_date = '2013-01-09')

patient <- createPatient()
encounter <- createEncounter()
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2016-12-31', dtstart = '2012-01-01', mhsacovg = '0')
declareTest(id = patient$person_id, "ICD10 Death and Death Type Correct. Id is PERSON_ID.")
add_inpatient_services(enrolid=patient$enrolid, year = '2016', svcdate = '2016-01-06', tsvcdat='2016-01-09', dxver = '0', dx1='I461')
expect_death(person_id = patient$person_id, death_type_concept_id = '32812')

patient <- createPatient()
encounter <- createEncounter()
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2015-12-31', dtstart = '2012-01-01', mhsacovg = '0')
declareTest(id = patient$person_id, "ICD9 Death and Death Type Correct. Id is PERSON_ID.")
add_inpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-01-06', tsvcdat='2013-01-09', dxver = '9', dx1='798')
expect_death(person_id = patient$person_id, death_type_concept_id = '32812')
}

}
23 changes: 13 additions & 10 deletions docs/IBM_CCAE_MDCR/Test Cases/R/DrugExposureTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ createDrugExposureTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '13533063670', year = '2012', svcdate = '2012-01-17')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '46275250', drug_exposure_start_date = '2012-01-17')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Drug exposure quantity - if not populated in source, leave it NULL. Id is PERSON_ID. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '13533063670', year = '2012', svcdate = '2012-01-19', metqty = NULL)
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '46275250', drug_exposure_start_date = '2012-01-19', quantity = NULL)

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -65,16 +72,12 @@ createDrugExposureTests <- function () {
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00069100101', year = '2014', svcdate = '2014-09-18')
expect_drug_exposure(person_id = patient$person_id, drug_source_concept_id = '45332969')

if (Sys.getenv("truvenType") == "CCAE")
{
patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "HRA Drug still has a DRUG_EXPOSURE_END_DATE (HIX-1433). Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_health_risk_assessment(enrolid = patient$enrolid, survdate = '2012-05-25', flu_shot = '1')
expect_drug_exposure(person_id = patient$person_id, drug_exposure_end_date = '2012-05-25', drug_concept_id = '4214838')

}
patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Event date is outside of observation_period, drug_exposure record created. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2014-12-31', dtstart = '2014-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00069100101', year = '2019', svcdate = '2019-09-18')
expect_drug_exposure(person_id = patient$person_id, drug_exposure_start_date = '2019-09-18')
}


2 changes: 1 addition & 1 deletion docs/IBM_CCAE_MDCR/Test Cases/R/LocationTests.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @export
createLocationTests <- function () {

if (truvenType != "MDCD") {
if (tolower(frameworkType) != "mdcd") {

patient<-createPatient()
declareTest(id = patient$person_id, "Location record generated for egeoloc 11. Id is PERSON_ID")
Expand Down
27 changes: 24 additions & 3 deletions docs/IBM_CCAE_MDCR/Test Cases/R/MeasurementTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
createMeasurementTests <- function () {


if (truvenType != "MDCD")
if (tolower(frameworkType) != "mdcd")
{

patient <- createPatient()
Expand Down Expand Up @@ -73,11 +73,25 @@ createMeasurementTests <- function () {

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "If you do not get a map from UCUM for UNIT_CONCEPT_ID then try JNJ_UNITS (HIX-1419). Id is PERSON_ID.")
declareTest(id = patient$person_id, "For UNIT_CONCEPT_ID UCUM lookup should not be used, use JNJ_UNITS istead. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_lab(enrolid = patient$enrolid, year='2012', svcdate = '2012-04-06', loinccd = '56789-1', result = '100', resunit = 'lbs.')
expect_measurement(person_id = patient$person_id, unit_concept_id = '8739')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "For UNIT_CONCEPT_ID UCUM lookup should not be used, use JNJ_UNITS istead. 586323 concept_id is expected. 9471 is a wrong UCUM derived unit. Id is a PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_lab(enrolid = patient$enrolid, year='2012', svcdate = '2012-04-06', loinccd = '56789-1', result = '100', resunit = 'C')
expect_measurement(person_id = patient$person_id, unit_concept_id = '586323')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has null in resunit, measurement record have unit_concept_id = NULL and unit_source_concept_id = NULL. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_lab(enrolid = patient$enrolid, year='2012', svcdate = '2012-04-06', loinccd = '56789-1', result = NULL, resunit = NULL)
expect_measurement(person_id = patient$person_id, unit_concept_id = NULL, unit_source_concept_id = NULL)

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "for LOINCs 3142-7, 29463-7, 3141-9 sometimes padded with 0000, strip padding (HIX-1418). Id is PERSON_ID.")
Expand All @@ -99,10 +113,17 @@ createMeasurementTests <- function () {
add_lab(enrolid = patient$enrolid, year='2012', svcdate = '2012-04-06', loinccd = '29463-7', result = '1950000', resunit = 'LBS')
expect_measurement(person_id = patient$person_id, value_as_number = '195', unit_concept_id = '8739')


patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Event date is outside of observation_period, measurement record created. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_lab(enrolid = patient$enrolid, year='2022', svcdate = '2022-04-06', loinccd = '29463-7', result = '1950000', resunit = 'LBS')
expect_measurement(person_id = patient$person_id, measurement_date = '2022-04-06')
}


if (truvenType == "CCAE")
if (tolower(frameworkType) == "ccae")
{

patient <- createPatient()
Expand Down
9 changes: 8 additions & 1 deletion docs/IBM_CCAE_MDCR/Test Cases/R/ObservationTests.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @export
createObservationTests <- function () {

if (truvenType == "CCAE")
if (tolower(frameworkType) == "ccae")
{

patient <- createPatient()
Expand Down Expand Up @@ -31,6 +31,13 @@ createObservationTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_health_risk_assessment(enrolid = patient$enrolid, survdate = '2012-05-25', flu_shot = '1')
expect_observation(person_id = patient$person_id, observation_source_value = 'FLU_SHOT')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Event date is outside of observation_period, observation record created. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_health_risk_assessment(enrolid = patient$enrolid, survdate = '2022-03-14', cgtpkamt = '2')
expect_observation(person_id = patient$person_id, observation_source_value = 'CGTPKAMT', value_as_number = '2.00', observation_date = '2022-03-14')

}
}
10 changes: 5 additions & 5 deletions docs/IBM_CCAE_MDCR/Test Cases/R/PayerPlanPeriodTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
createPayerPlanPeriodTests <- function () {

if (truvenType != "MDCD") {
if (tolower(frameworkType) != "mdcd") {

patient<-createPatient()
declareTest(id = patient$person_id, "Person does not have prescription benefits and is excluded. Id is PERSON_ID.")
Expand All @@ -11,7 +11,7 @@ createPayerPlanPeriodTests <- function () {

}

if (truvenType == "CCAE") {
if (tolower(frameworkType) == "ccae") {
patient<-createPatient()
declareTest(id = patient$person_id, "Person has a gap of >32 days between enrollment periods with the same payer_source_value; person has two records. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtstart="2013-01-01", dtend="2013-01-31", datatyp="1", plantyp="6")
Expand Down Expand Up @@ -47,7 +47,7 @@ createPayerPlanPeriodTests <- function () {

}

if (truvenType == "MDCR") {
if (tolower(frameworkType) == "mdcr") {
patient<-createPatient()
declareTest(id = patient$person_id, "Person has a gap of >32 days between enrollment periods with the same payer_source_value; person has two records. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtstart="2013-01-01", dtend="2013-01-31", datatyp="1", plantyp="6")
Expand All @@ -69,7 +69,7 @@ createPayerPlanPeriodTests <- function () {
expect_payer_plan_period(person_id=patient$person_id, payer_plan_period_start_date="2012-04-01", payer_plan_period_end_date="2012-04-30", payer_source_value="C Medicare PPO")
}

if (truvenType == "MDCD") {
if (tolower(frameworkType) == "mdcd") {

patient<-createPatient()
declareTest(id = patient$person_id, "Person has a gap of >32 days between enrollment periods with the same payer_source_value; person has two records. Id is PERSON_ID.")
Expand All @@ -80,7 +80,7 @@ createPayerPlanPeriodTests <- function () {

patient<-createPatient()
declareTest(id = patient$person_id, "Person does not have prescription benefits and is excluded. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtstart="2013-01-01", dtend="2013-01-31", plantyp="6", drugcovg ="0")
add_enrollment_detail(enrolid=patient$enrolid, dtstart="2013-01-01", dtend="2013-01-31", plantyp="6", drugcovg ="0", medicare="0")
expect_no_payer_plan_period(person_id = patient$person_id)

patient<-createPatient()
Expand Down
11 changes: 8 additions & 3 deletions docs/IBM_CCAE_MDCR/Test Cases/R/PersonTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ createPersonTests <- function () {
declareTest(id = patient$person_id, "Person with sex=3 is excluded. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, sex="3")
expect_no_person(person_id = patient$person_id)


patient<-createPatient()
declareTest(id = patient$person_id, "Person born after current year. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dobyr="2032")
expect_no_person(person_id = patient$person_id)

patient<-createPatient()
declareTest(id = patient$person_id, "Person has record with sex=3 but last record has sex=1, person is kept. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend="2012-01-31", dtstart="2012-01-01", sex="3")
Expand All @@ -62,7 +67,7 @@ createPersonTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend="2012-04-30", dtstart="2012-04-01", dobyr="2012")
expect_person(person_id=patient$person_id, year_of_birth="2012", month_of_birth="4", day_of_birth="1")

if (truvenType != "MDCD")
if (tolower(frameworkType) != "mdcd")
{
patient<-createPatient()
declareTest(id = patient$person_id, "Person with Rx benefits is kept. Id is PERSON_ID.")
Expand All @@ -81,7 +86,7 @@ createPersonTests <- function () {
expect_person(person_id=patient$person_id)
}

if (truvenType == "MDCD")
if (tolower(frameworkType) == "mdcd")
{
patient<-createPatient()
declareTest(id = patient$person_id, "Person with two birth years >2 yrs apart is included because max(DOBYR) > 90. Id is PERSON_ID.")
Expand Down
Loading

0 comments on commit 4de3ca1

Please sign in to comment.