Skip to content

Commit

Permalink
Merge pull request #26 from OHDSI/ccae_unit_tests_renovation_2023
Browse files Browse the repository at this point in the history
tests updated
  • Loading branch information
bradanton authored Oct 4, 2023
2 parents 4123ce0 + e8e5f0c commit 9cb15a1
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 114 deletions.
36 changes: 18 additions & 18 deletions docs/IBM_CCAE_MDCR/Test Cases/R/ConditionOccurrenceTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ createConditionOccurrenceTests <- function () {
add_inpatient_admissions(enrolid=patient$enrolid, pdx = '0092', caseid = encounter$caseid, dxver = '9', year = '2012')
#expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '4008576', condition_status_concept_id = '32902', condition_type_concept_id = '32854')
#expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '198337', condition_status_concept_id = '32902', condition_type_concept_id = '32855' )
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '4008576', condition_type_concept_id = '38000183')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '198337', condition_type_concept_id = '38000199' )
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '4008576', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '198337', condition_type_concept_id = '32855' )

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -22,8 +22,8 @@ createConditionOccurrenceTests <- function () {
add_facility_header(enrolid=patient$enrolid, svcdate = '2012-10-16', tsvcdat = '2012-10-16', dx9 = '1024', fachdid = encounter$caseid, dxver='9')
#expect_condition_occurrence(person_id = patient$person_id, condition_concept_id='433706', condition_status_concept_id = '32902', condition_type_concept_id = '32860')
#expect_condition_occurrence(person_id = patient$person_id, condition_concept_id='433706', condition_status_concept_id = '32902', condition_type_concept_id = '32846')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id='433706', condition_type_concept_id = '38000215')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id='433706', condition_type_concept_id = '38000238')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id='433706', condition_type_concept_id = '32846', condition_status_source_value = 'DX1')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id='433706', condition_type_concept_id = '32846', condition_status_source_value = 'DX9')


patient <- createPatient()
Expand All @@ -32,7 +32,7 @@ createConditionOccurrenceTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid = patient$enrolid, svcdate = '2012-07-23', tsvcdat = '2012-07-23', dx4='57411', dxver='9')
#expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_status_concept_id = '32908', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_type_concept_id = '38000187')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_type_concept_id = '32854', condition_status_source_value = 'DX4')

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -41,7 +41,7 @@ createConditionOccurrenceTests <- function () {
add_inpatient_services(enrolid=patient$enrolid, fachdid = encounter$caseid, admdate = '2012-07-23', svcdate = '2012-07-23', tsvcdat = '2012-07-23', year = '2012')
add_facility_header(enrolid=patient$enrolid, fachdid = encounter$caseid, svcdate = '2012-07-23', tsvcdat = '2012-07-23', dx9 = '4760', dxver = '9', year = '2012')
#expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '24970', condition_status_concept_id = '32908', condition_type_concept_id = '32846')
expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '24970', condition_type_concept_id = '38000208')
expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '24970', condition_type_concept_id = '32854', condition_status_source_value = 'DX9')

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -51,8 +51,8 @@ createConditionOccurrenceTests <- function () {
expect_visit_occurrence(person_id = patient$person_id, visit_concept_id = '9203')
# expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '195587', condition_status_concept_id = '32902', condition_type_concept_id = '32854')
# expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '24970', condition_status_concept_id = '32902', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '195587', condition_type_concept_id = '38000184')
expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '24970', condition_type_concept_id = '38000183')
expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '195587', condition_type_concept_id = '32854', condition_status_source_value = 'DX1')
expect_condition_occurrence(person_id=patient$person_id, condition_concept_id = '24970', condition_type_concept_id = '32854', condition_status_source_value = 'PDX')

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -61,8 +61,8 @@ createConditionOccurrenceTests <- function () {
add_inpatient_services(enrolid=patient$enrolid, svcdate = '2012-10-15', tsvcdat = '2012-10-17', pdx = 'V5302', dxver='9')
# expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4047347', procedure_type_concept_id = '32854')
# expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '46272569', procedure_type_concept_id = '32854')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4047347', procedure_type_concept_id = '38000183')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '46272569', procedure_type_concept_id = '38000183')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4047347', procedure_type_concept_id = '32854')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '46272569', procedure_type_concept_id = '32854')


patient <- createPatient()
Expand All @@ -71,23 +71,23 @@ createConditionOccurrenceTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid=patient$enrolid, pdx = 'E0152', svcdate = '2012-02-04', tsvcdat = '2012-02-08', dxver = '9')
# expect_observation(person_id = patient$person_id, observation_concept_id = '4117957', observation_type_concept_id = '32854')
expect_observation(person_id = patient$person_id, observation_concept_id = '4117957', observation_type_concept_id = '38000183')
expect_observation(person_id = patient$person_id, observation_concept_id = '4117957', observation_type_concept_id = '32854')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has diagnosis in a dx field that has domain=measurement, condition record moved to measurement. 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 = '2012-08-21', tsvcdat = '2012-08-25', pdx = 'V726', dxver='9')
# expect_measurement(person_id = patient$enrolid, measurement_concept_id = '4034850', measurement_type_concept_id = '32854')
expect_measurement(person_id = patient$enrolid, measurement_concept_id = '4034850', measurement_type_concept_id = '38000183')
expect_measurement(person_id = patient$enrolid, measurement_concept_id = '4034850', measurement_type_concept_id = '32854')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has icd10 diagnosis in a dx field with dxver=0, condition record created with icd10 mapped to snomed. 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 = '2012-08-09', tsvcdat = '2012-08-12', dx1='S42241S', dxver='0')
# expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '438021', condition_status_concept_id = '32902', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '438021', condition_type_concept_id = '38000184')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '438021', condition_type_concept_id = '32854')

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -96,7 +96,7 @@ createConditionOccurrenceTests <- function () {
add_inpatient_services(enrolid=patient$enrolid, svcdate = '2012-08-09', tsvcdat = '2012-08-12', dx1='V9001', dxver='0')
# expect_observation(person_id = patient$person_id, observation_concept_id = '4155106', observation_type_concept_id = '32854')
# expect_no_condition_occurrence(person_id = patient$person_id, condition_concept_id = '46270117')
expect_observation(person_id = patient$person_id, observation_concept_id = '4155106', observation_type_concept_id = '38000184')
expect_observation(person_id = patient$person_id, observation_concept_id = '4155106', observation_type_concept_id = '32854')
expect_no_condition_occurrence(person_id = patient$person_id, condition_concept_id = '46270117')

patient <- createPatient()
Expand All @@ -105,15 +105,15 @@ createConditionOccurrenceTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2015-12-31', dtstart = '2015-01-01')
add_inpatient_services(enrolid=patient$enrolid, admdate= '2015-11-09', svcdate = '2015-11-09', tsvcdat = '2015-11-12', dx1='S42241S', dxver='')
# expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '438021', condition_source_concept_id = '45602528', condition_status_concept_id = '32902', condition_type_concept_id = '32854')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '438021', condition_source_concept_id = '45602528', condition_type_concept_id = '38000184')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '438021', condition_source_concept_id = '45602528', condition_type_concept_id = '32854')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has icd9 diagnosis before 10/1/2015 in a dx field with dxver=null, used ICD9. Id is PERSON_ID")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid=patient$enrolid, admdate = '2012-08-09', svcdate = '2012-08-09', tsvcdat = '2012-08-12', dx1='V9001', dxver='')
# expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '46270117', condition_source_concept_id = '44821630', condition_status_concept_id = '32902', condition_type_concept_id = '32854' )
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '46270117', condition_source_concept_id = '44821630', condition_type_concept_id = '38000184' )
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '46270117', condition_source_concept_id = '44821630', condition_type_concept_id = '32854' )

#This will test HIX-1274
patient <- createPatient()
Expand All @@ -124,8 +124,8 @@ createConditionOccurrenceTests <- function () {
add_inpatient_services(enrolid = patient$enrolid, svcdate = '2012-08-02', tsvcdat = '2012-08-02', dx4='57411', dxver='9')
# expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_status_concept_id = '32908', condition_start_date = '2012-07-01', condition_type_concept_id = '32854')
# 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 = '38000187')
expect_condition_occurrence(person_id = patient$person_id, condition_concept_id = '195587', condition_start_date = '2012-08-02', condition_type_concept_id = '38000187')
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')

if (truvenType == "MDCD")
{
Expand Down
8 changes: 4 additions & 4 deletions docs/IBM_CCAE_MDCR/Test Cases/R/DeathTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ createDeathTests <- function () {
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 = '38003567')
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 = '38003567')
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')
declareTest(id = patient$person_id, "Discharge Status and Death Type Correct. Id is PERSON_ID.")
add_inpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-01-06', tsvcdat='2013-01-09', dstatus = '20')
expect_death(person_id = patient$person_id, death_type_concept_id = '38003566')
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, "Death by ICD9 and Death by Discharge, Keep the Discharge. Id is PERSON_ID.")
add_inpatient_services(enrolid=patient$enrolid, year = '2013', svcdate = '2013-01-06', tsvcdat='2013-01-09', dstatus = '20',dxver = '9', dx1='798')
expect_death(person_id = patient$person_id, death_type_concept_id = '38003566')
expect_death(person_id = patient$person_id, death_type_concept_id = '32812')

patient <- createPatient()
encounter <- createEncounter()
Expand Down
8 changes: 4 additions & 4 deletions docs/IBM_CCAE_MDCR/Test Cases/R/DrugEraTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ createDrugEraTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '02-04-2012', daysupp = 8)
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '02-22-2012', daysupp = 30)
expect_drug_era(person_id = patient$person_id, drug_concept_id = '1134439', drug_era_start_date ='02-04-2012', gap_days = 10)
expect_drug_era(person_id = patient$person_id, drug_concept_id = '1134439', drug_era_start_date ='02-04-2012', gap_days = 11)

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -24,7 +24,7 @@ createDrugEraTests <- function () {
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '02-04-2012', daysupp = 13)
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '02-22-2012', daysupp = 14)
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '03-12-2012', daysupp = 30)
expect_drug_era(person_id = patient$person_id, drug_concept_id = '1134439', drug_era_start_date ='02-04-2012', gap_days = 10)
expect_drug_era(person_id = patient$person_id, drug_concept_id = '1134439', drug_era_start_date ='02-04-2012', gap_days = 12)
expect_count_drug_era(rowCount = 1, person_id = patient$person_id)

patient <- createPatient()
Expand All @@ -41,7 +41,7 @@ createDrugEraTests <- function () {
declareTest(id = patient$person_id, "Drug_era_end_date should be drug start date + days supply. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2010-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00349835305', year = '2012', svcdate = '12-08-2010', daysupp = '14')
expect_drug_era(person_id = patient$person_id, drug_concept_id = '956874', drug_era_start_date ='12-08-2010', drug_era_end_date = '12-22-2010')
expect_drug_era(person_id = patient$person_id, drug_concept_id = '956874', drug_era_start_date ='12-08-2010', drug_era_end_date = '12-21-2010')

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -64,6 +64,6 @@ createDrugEraTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '12-12-2011', daysupp = 30)
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00463303410', year = '2012', svcdate = '01-08-2012', daysupp = 30)
expect_drug_era(person_id = patient$person_id, drug_concept_id = '1134439', drug_era_start_date ='01-08-2012', gap_days = 0)
## expect_drug_era(person_id = patient$person_id, drug_concept_id = '1134439', drug_era_start_date ='01-08-2012', gap_days = 0)

}
5 changes: 3 additions & 2 deletions docs/IBM_CCAE_MDCR/Test Cases/R/DrugExposureTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ createDrugExposureTests <- function () {
declareTest(id = patient$person_id, "CPT4 drug code in inpatient record moves to drug_exposure. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid = patient$enrolid, proc1 = '90376', svcdate = '2012-08-09', tsvcdat = '2012-08-12', caseid = encounter$caseid, year = '2012')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '46233994', drug_exposure_start_date = '2012-08-09')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '46234006', drug_exposure_start_date = '2012-08-09')

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Days supply is NULL but DRUG_EXPOSURE_END_DATE is set to DRUG_EXPOSURE_START_DATE (HIX-1430). Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_inpatient_services(enrolid = patient$enrolid, proc1 = '90376', svcdate = '2012-08-09', tsvcdat = '2012-08-12', caseid = encounter$caseid, year = '2012')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '46233994', drug_exposure_start_date = '2012-08-09', drug_exposure_end_date = '2012-08-09')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '46234006', drug_exposure_start_date = '2012-08-09', drug_exposure_end_date = '2012-08-09')

patient <- createPatient()
encounter <- createEncounter()
Expand Down Expand Up @@ -64,6 +64,7 @@ createDrugExposureTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2014-12-31', dtstart = '2014-01-01')
add_drug_claims(enrolid = patient$enrolid, ndcnum = '00069100101', year = '2014', svcdate = '09-18-2014')
expect_drug_exposure(person_id = patient$person_id, drug_source_concept_id = '45332969')


if (Sys.getenv("truvenType") == "CCAE")
{
Expand Down
Loading

0 comments on commit 9cb15a1

Please sign in to comment.