Skip to content

Commit

Permalink
Merge pull request #73 from OHDSI/new_vocab_unit_test_fixes
Browse files Browse the repository at this point in the history
New vocab unit test fixes
  • Loading branch information
clairblacketer committed May 14, 2024
2 parents e83de6f + 090f9ca commit 402fe73
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 136 deletions.
10 changes: 5 additions & 5 deletions docs/CPRD/Test Cases/R/measurementTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ createMeasurementTests <- function()
expect_measurement(person_id = lookup_person("person_id", person_source_value = patient$person_id), measurement_concept_id=4132152,
measurement_date='2012-01-01',
value_source_value='Normal',
measurement_source_value='424Z.00', value_as_concept_id=45884153)
measurement_source_value='424Z.00', value_as_concept_id=4069590)


# TESTING VALUES RANGE LOW (TEST.data2)
Expand All @@ -129,7 +129,7 @@ createMeasurementTests <- function()
expect_measurement(person_id = lookup_person("person_id", person_source_value = patient$person_id), measurement_concept_id=4132152,
measurement_date='2012-01-01', range_low = 1.2,
measurement_type_concept_id=32856, value_source_value='Normal',
value_as_concept_id=45884153)
value_as_concept_id=4069590)


# TESTING VALUES RANGE HIGH (TEST.data3)
Expand All @@ -144,7 +144,7 @@ createMeasurementTests <- function()
expect_measurement(person_id = lookup_person("person_id", person_source_value = patient$person_id), measurement_concept_id=4132152,
measurement_date='2012-01-01', range_high = 4.3,
measurement_type_concept_id=32856, value_source_value='Normal',
value_as_concept_id=45884153)
value_as_concept_id=4069590)


# 19) -- test observation record 7 fields -- enntype 173 maps to 3000963 --> SHOULD WORK!
Expand Down Expand Up @@ -298,12 +298,12 @@ createMeasurementTests <- function()
add_consultation(patid = patient$patid, eventdate = '2010-01-01', staffid = 1001)
expect_measurement(person_id = lookup_person("person_id", person_source_value = patient$person_id), measurement_date='2010-01-01', value_as_number=80,
measurement_source_value='1-Examination Findings-Blood pressure-Diastolic', measurement_type_concept_id=32817,
measurement_concept_id=4154790)
measurement_concept_id=3012888)

declareTest(id = patient$person_id, '2) additional observation')
expect_measurement(person_id = lookup_person("person_id", person_source_value = patient$person_id),measurement_date='2010-01-01', value_as_number=160,
measurement_source_value='1-Examination Findings-Blood pressure-Systolic', measurement_type_concept_id=32817,
measurement_concept_id=4152194)
measurement_concept_id=3004249)

#observation_table: 3) person_id=1361111;observation_date=2012-01-01; value_as_numbr=5; observation_source_value='1-3'; observation_type _type_concept_id=44818701 4) '1-5' value_source_value='Midline' )

Expand Down
2 changes: 1 addition & 1 deletion docs/IBM_CCAE_MDCR/Test Cases/R/DrugExposureTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ createDrugExposureTests <- function () {
declareTest(id = patient$person_id, "Negative daysupp should be 0 in cdm. 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 = '58864060830', year = '2012', daysupp = '-30', svcdate = '2012-06-12')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '1545998', days_supply = '0', drug_exposure_start_date = '2012-06-12')
expect_drug_exposure(person_id = patient$person_id, drug_concept_id = '1545998', days_supply = '1', drug_exposure_start_date = '2012-06-12')

patient <- createPatient()
encounter <- createEncounter()
Expand Down
21 changes: 11 additions & 10 deletions docs/IBM_CCAE_MDCR/Test Cases/R/ProcedureOccurrenceTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ createProcedureOccurrenceTests <- function () {
add_inpatient_admissions(enrolid = patient$enrolid, admdate = '2012-10-20', caseid = encounter$caseid, year = '2012')
add_inpatient_services(enrolid = patient$enrolid, caseid = encounter$caseid, svcdate = '2012-10-20', tsvcdat = '2012-10-22', provid = '3456789', proc1 = '50760', stdprov = '220', year = '2012')
add_inpatient_services(enrolid = patient$enrolid, caseid = encounter$caseid, svcdate = '2012-10-20', tsvcdat = '2012-10-22', provid = '1234567', proc1 = '50760', stdprov = '540', year = '2012')
# expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2109659', procedure_date = '2012-10-20', procedure_type_concept_id = '32854', rowCount = 2)
expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2109659', procedure_date = '2012-10-20', rowCount = 2)
# expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4021253', procedure_date = '2012-10-20', procedure_type_concept_id = '32854', rowCount = 2)
expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4021253', procedure_date = '2012-10-20', rowCount = 2)

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has HCPCS procedure code with value in PROCMOD. Id is PERSON_ID.")
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_outpatient_services(enrolid = patient$enrolid, proc1 = 'C9727', procmod = 'P1',svcdate = '2012-05-12', tsvcdat = '2012-05-12')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2616464', procedure_date = '2012-05-12', modifier_concept_id = '4320556')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4196153', procedure_date = '2012-05-12', modifier_concept_id = '4320556')

}

Expand All @@ -64,14 +64,15 @@ createProcedureOccurrenceTests <- function () {
add_inpatient_admissions(enrolid = patient$enrolid, caseid = encounter$caseid, year = '2012')
add_inpatient_services(enrolid = patient$enrolid, caseid = encounter$caseid, svcdate = '2012-10-20', tsvcdat = '2012-10-22', prov_id = '3456789', proc1 = '50760', stdprov = '220', year = '2012')
add_inpatient_services(enrolid = patient$enrolid, caseid = encounter$caseid, svcdate = '2012-10-20', tsvcdat = '2012-10-22', prov_id = '1234567', proc1 = '50760', stdprov = '540', year = '2012')
expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2109659', procedure_date = '2012-10-20', rowCount = 2)
expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4021253', procedure_date = '2012-10-20', rowCount = 2)

patient <- createPatient()
encounter <- createEncounter()
declareTest(id = patient$person_id, "Patient has procedure in proc1 field in long_term_care table. 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, svcdate = '2012-09-15', tsvcdat = '2012-10-30', proc1 = '92568' )
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2313736', procedure_date = '2012-09-15')
## expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2313736', procedure_date = '2012-09-15')
expect_measurement(person_id = patient$person_id, measurement_concept_id= '4167674', measurement_date = '2012-09-15')
}

patient <- createPatient()
Expand All @@ -80,9 +81,9 @@ createProcedureOccurrenceTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_outpatient_services(enrolid = patient$enrolid, fachdid = encounter$caseid, proc1 = '54861', svcdate = '2012-02-15', tsvcdat = '2012-02-15', year = '2012')
add_facility_header(enrolid = patient$enrolid, fachdid = encounter$caseid, proc1 = '54861', svcdate = '2012-02-15', tsvcdat = '2012-02-15', year = '2012')
expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2109995', procedure_date = '2012-02-15', procedure_type_concept_id = '32846', rowCount = 2)
## expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2109995', procedure_date = '2012-02-15', procedure_type_concept_id = '32846')
## expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2109995', procedure_date = '2012-02-15', procedure_type_concept_id = '32846')
expect_count_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4200063', procedure_date = '2012-02-15', procedure_type_concept_id = '32846', rowCount = 2)
## expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4200063', procedure_date = '2012-02-15', procedure_type_concept_id = '32846')
## expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4200063', procedure_date = '2012-02-15', procedure_type_concept_id = '32846')

patient <- createPatient()
encounter <- createEncounter()
Expand All @@ -99,12 +100,12 @@ createProcedureOccurrenceTests <- function () {
add_enrollment_detail(enrolid=patient$enrolid, dtend = '2012-12-31', dtstart = '2012-01-01')
add_outpatient_services(enrolid = patient$enrolid, fachdid = encounter$caseid, svcdate = '2012-03-03', tsvcdat = '2012-03-03', year = '2012')
add_facility_header(enrolid = patient$enrolid, fachdid = encounter$caseid, proc1 = '96900', proc2 = '97811', proc3 = '92570',proc4 = '92568',proc5 = '97780', proc6 = '0093U', svcdate = '2012-03-03', tsvcdat = '2012-03-03', year = '2012')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2314252', procedure_type_concept_id = '32846' )
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '4180942', procedure_type_concept_id = '32846' )
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2314322', procedure_type_concept_id = '32846' )
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '40757149', procedure_type_concept_id = '32846' )
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '2313736', procedure_type_concept_id = '32846' )
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '42739018', procedure_type_concept_id = '32846' )
## expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = '709845', procedure_type_concept_id = '32846' )
expect_measurement(person_id = patient$person_id, measurement_concept_id = '4167674', measurement_type_concept_id = '32846' )
expect_measurement(person_id = patient$person_id, measurement_concept_id= '709845', measurement_type_concept_id = '32846')


Expand Down
17 changes: 3 additions & 14 deletions docs/IBM_CCAE_MDCR/Test Cases/extras/IBMMDCR_TestingFramework.R
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ initFramework <- function() {
defaults$wgtkey <- ''
defaults$year <- '2011'
defaults$medadv <- ''
defaults$gpi <- '34000003100330'
assign('drug_claims', defaults, envir = frameworkContext$defaultValues)

defaults <- list()
Expand Down Expand Up @@ -2112,7 +2111,7 @@ set_defaults_inpatient_admissions <- function(flag, admdate, admtyp, age, agegrp
invisible(defaults)
}

set_defaults_drug_claims <- function(flag, age, agegrp, awp, cap_svc, cob, coins, copay, datatyp, dawind, daysupp, deaclas, deduct, dispfee, dobyr, eeclass, eestatu, efamid, egeoloc, eidflag, emprel, enrflag, enrolid, generid, genind, hlthplan, indstry, ingcost, maintin, metqty, mhsacovg, msa, ndcnum, netpay, ntwkprov, paidntwk, pay, pddate, pharmid, phyflag, plankey, plantyp, qty, refill, region, rxmr, saletax, seqnum, sex, svcdate, thercls, thergrp, version, wgtkey, year, medadv, gpi) {
set_defaults_drug_claims <- function(flag, age, agegrp, awp, cap_svc, cob, coins, copay, datatyp, dawind, daysupp, deaclas, deduct, dispfee, dobyr, eeclass, eestatu, efamid, egeoloc, eidflag, emprel, enrflag, enrolid, generid, genind, hlthplan, indstry, ingcost, maintin, metqty, mhsacovg, msa, ndcnum, netpay, ntwkprov, paidntwk, pay, pddate, pharmid, phyflag, plankey, plantyp, qty, refill, region, rxmr, saletax, seqnum, sex, svcdate, thercls, thergrp, version, wgtkey, year, medadv) {
defaults <- get('drug_claims', envir = frameworkContext$defaultValues)
if (!missing(flag)) {
defaults$flag <- flag
Expand Down Expand Up @@ -2282,9 +2281,7 @@ set_defaults_drug_claims <- function(flag, age, agegrp, awp, cap_svc, cob, coins
if (!missing(medadv)) {
defaults$medadv <- medadv
}
if (!missing(gpi)) {
defaults$gpi <- gpi
}

assign('drug_claims', defaults, envir = frameworkContext$defaultValues)
invisible(defaults)
}
Expand Down Expand Up @@ -6478,7 +6475,7 @@ add_inpatient_admissions <- function(flag, admdate, admtyp, age, agegrp, caseid,
invisible(NULL)
}

add_drug_claims <- function(flag, age, agegrp, awp, cap_svc, cob, coins, copay, datatyp, dawind, daysupp, deaclas, deduct, dispfee, dobyr, eeclass, eestatu, efamid, egeoloc, eidflag, emprel, enrflag, enrolid, generid, genind, hlthplan, indstry, ingcost, maintin, metqty, mhsacovg, msa, ndcnum, netpay, ntwkprov, paidntwk, pay, pddate, pharmid, phyflag, plankey, plantyp, qty, refill, region, rxmr, saletax, seqnum, sex, svcdate, thercls, thergrp, version, wgtkey, year, medadv, gpi) {
add_drug_claims <- function(flag, age, agegrp, awp, cap_svc, cob, coins, copay, datatyp, dawind, daysupp, deaclas, deduct, dispfee, dobyr, eeclass, eestatu, efamid, egeoloc, eidflag, emprel, enrflag, enrolid, generid, genind, hlthplan, indstry, ingcost, maintin, metqty, mhsacovg, msa, ndcnum, netpay, ntwkprov, paidntwk, pay, pddate, pharmid, phyflag, plankey, plantyp, qty, refill, region, rxmr, saletax, seqnum, sex, svcdate, thercls, thergrp, version, wgtkey, year, medadv) {
defaults <- get('drug_claims', envir = frameworkContext$defaultValues)
fields <- c()
values <- c()
Expand Down Expand Up @@ -6930,14 +6927,6 @@ add_drug_claims <- function(flag, age, agegrp, awp, cap_svc, cob, coins, copay,
fields <- c(fields, "medadv")
values <- c(values, if (is.null(medadv)) "NULL" else if (is(medadv, "subQuery")) paste0("(", as.character(medadv), ")") else paste0("'", as.character(medadv), "'"))

if (missing(gpi)) {
gpi <- defaults$gpi
} else {
frameworkContext$sourceFieldsTested <- c(frameworkContext$sourceFieldsTested, 'drug_claims.gpi')
}
fields <- c(fields, "_gpi")
values <- c(values, if (is.null(gpi)) "NULL" else if (is(gpi, "subQuery")) paste0("(", as.character(gpi), ")") else paste0("'", as.character(gpi), "'"))

inserts <- list(testId = frameworkContext$testId, testDescription = frameworkContext$testDescription, table = "drug_claims", fields = fields, values = values)
frameworkContext$inserts[[length(frameworkContext$inserts) + 1]] <- inserts
invisible(NULL)
Expand Down
6 changes: 3 additions & 3 deletions docs/OPTUM_PANTHER/Test Cases/R/DrugExposureTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ createDrugExposureTests <- function () {
add_patient(ptid = patient$ptid, first_month_active = '201005', last_month_active = '201212')
add_medication_administrations(ptid=patient$ptid, ndc="55111067101", order_date='2011-01-07', encid=enc$encid)
add_medication_administrations(ptid=patient$ptid, ndc="55111067101", order_date='2011-01-07', encid=enc$encid)
expect_count_drug_exposure(rowCount = 2, person_id = patient$person_id, drug_exposure_start_date = '2011-01-07', drug_source_value = '55111067101')

expect_count_drug_exposure(rowCount = 1, person_id = patient$person_id, drug_exposure_start_date = '2011-01-07', drug_source_value = '55111067101') # distinct was added to the MEDICATION_ADMINISTRATIONS table
patient <- createPatient();
enc <- createEncounter();
enc2 <- createEncounter();
Expand Down Expand Up @@ -358,7 +358,7 @@ createDrugExposureTests <- function () {
declareTest("Patient has PROCEDURE with HCPCS proc_code that maps to a standard concept", id = patient$person_id)
add_patient(ptid = patient$ptid, first_month_active = '201005', last_month_active = '201212')
add_procedure(ptid = patient$ptid, proc_date="2011-10-12", proc_code="J9310", proc_code_type="HCPCS")
expect_drug_exposure(person_id = patient$person_id, drug_concept_id="43148859", drug_source_value="J9310", drug_source_concept_id="2718907")
expect_drug_exposure(person_id = patient$person_id, drug_concept_id="46275081", drug_source_value="J9310", drug_source_concept_id="2718907")

# TODO: provider_id auto generated, need to find way to get correct id
# patient <- createPatient();
Expand Down
8 changes: 4 additions & 4 deletions docs/OPTUM_PANTHER/Test Cases/R/MeasurementTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ createMeasurementTests <- function () {
add_patient(ptid=patient$ptid, birth_yr = 1950, gender = 'Male',
first_month_active = '200701', last_month_active = '201001')
add_encounter(ptid=patient$ptid, encid = enc$encid, interaction_type='Inpatient', interaction_date='2009-01-01')
add_labs(ptid=patient$ptid, encid = enc$encid, test_name='Oxygen saturation (SpO2).pulse oximetry', test_result='100', result_date='2009-01-01')
add_labs(ptid=patient$ptid, encid = enc$encid, test_name='Oxygen.partial pressure (PO2).unspecified specimen', test_result='100', result_date='2009-01-01')
expect_measurement(person_id=patient$person_id,measurement_concept_id=3027315,measurement_date='2009-01-01',
measurement_source_value='Oxygen saturation (SpO2).pulse oximetry', measurement_source_concept_id=0,
measurement_source_value='Oxygen.partial pressure (PO2).unspecified specimen', measurement_source_concept_id=0,
value_as_number=100)

patient <- createPatient();
Expand All @@ -74,9 +74,9 @@ createMeasurementTests <- function () {
add_patient(ptid=patient$ptid, birth_yr = 1950, gender = 'Male',
first_month_active = '200701', last_month_active = '201001')
add_encounter(ptid=patient$ptid, encid = enc$encid, interaction_type='Inpatient', interaction_date='2009-01-01')
add_labs(ptid=patient$ptid, encid = enc$encid, test_name='Oxygen saturation (SpO2).pulse oximetry', test_result='positive', result_date='2009-01-01')
add_labs(ptid=patient$ptid, encid = enc$encid, test_name='Oxygen.partial pressure (PO2).unspecified specimen', test_result='positive', result_date='2009-01-01')
expect_measurement(person_id=patient$person_id,measurement_concept_id=3027315,measurement_date='2009-01-01',
measurement_source_value='Oxygen saturation (SpO2).pulse oximetry', measurement_source_concept_id=0,
measurement_source_value='Oxygen.partial pressure (PO2).unspecified specimen', measurement_source_concept_id=0,
value_as_number=NULL, value_as_concept_id=45884084)

patient <- createPatient();
Expand Down
2 changes: 1 addition & 1 deletion docs/OPTUM_PANTHER/Test Cases/R/ProcedureOccurrenceTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ createProcedureOccurrenceTests <- function () {
add_patient(ptid=patient$ptid, birth_yr = 1950, gender = 'Male',
first_month_active = '200701', last_month_active = '201001')
add_procedure(ptid=patient$ptid, proc_code = '36415', proc_code_type = 'CPT4', proc_date = '2009-01-01')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = 2108115, procedure_source_value = '36415')
expect_procedure_occurrence(person_id = patient$person_id, procedure_concept_id = 4102442, procedure_source_value = '36415')


patient <- createPatient();
Expand Down
12 changes: 4 additions & 8 deletions docs/OPTUM_PANTHER/Test Cases/extras/Optum_Panther_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ CREATE TABLE immunizations
ndc varchar(11),
ndc_source varchar(7),
pt_reported char(1),
sourceid varchar(5),
_gpi varchar(14)
sourceid varchar(5)
);


Expand Down Expand Up @@ -147,8 +146,7 @@ CREATE TABLE medication_administrations
generic_desc varchar(60),
drug_class varchar(150),
discontinue_reason varchar(46),
sourceid varchar(5),
_gpi varchar(14)
sourceid varchar(5)
);


Expand Down Expand Up @@ -349,8 +347,7 @@ CREATE TABLE patient_reported_medications
dose_frequency varchar(30),
generic_desc varchar(60),
drug_class varchar(150),
sourceid varchar(5),
_gpi varchar(14)
sourceid varchar(5)
);


Expand All @@ -376,8 +373,7 @@ CREATE TABLE prescriptions_written
generic_desc varchar(60),
drug_class varchar(150),
discontinue_reason varchar(46),
sourceid varchar(5),
_gpi varchar(14)
sourceid varchar(5)
);


Expand Down

0 comments on commit 402fe73

Please sign in to comment.