# ---
# title: Medical Codes
# ---

library(readxl)
#library(rmarkdown)
library(printr)
## Registered S3 method overwritten by 'printr':
##   method                from     
##   knit_print.data.frame rmarkdown
options(width=80)
### "-----------------------------------"
xl <-
  "C:/zz/data/xlsx/2019 HEDIS for the Quality Rating System VSD 10_01_2018.xlsx"
df <- read_excel(xl , sheet = "Summary of Changes - Codes")
attach(df)
knitr::kable(  summary(df))
Value Set Change Code System Code Revised
Length:9159 Length:9159 Length:9159 Length:9159 Length:9159
Class :character Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character Mode :character
knitr::kable(  names(df))
x
Value Set
Change
Code System
Code
Revised
# [1] "Value Set"   "Change"      "Code System" "Code"        "Revised"
knitr::kable(  table(`Value Set`,Change))
Added Deleted
Absence of Cervix 1 0
Acute Condition 60 8673
AOD Abuse and Dependence 1 0
BH Outpatient 1 0
Bilateral Modifier 0 1
BMI 0 1
BMI Percentile 0 1
Comorbid Conditions 0 1
Competing Diagnosis 2 1
Cytomegalovirus Antibody 0 2
Chemical Dependency 11 0
Chlamydia Tests 11 11
Diabetes 2 1
Diabetes Exclusions 0 1
Diabetic Retinal Screening 0 1
Diagnostic Radiology 7 6
Encephalopathy Due To Vaccination 1 1
ESRD 3 0
Hepatitis B 0 1
IET Stand Alone Visits 1 0
Imaging Study 0 1
Intentional Self-Harm 3 0
IV Drug Abuse 4 1
Major Depression 0 1
Malignant Neoplasm of Lymphatic Tissue 4 1
Malignant Neoplasms 12 0
Measles 0 1
Meningococcal Vaccine Administered 2 0
Mental Health Diagnosis 4 0
Mental Illness 3 0
Mumps 0 1
Neurologic Impairment 0 1
Non-live Births 12 1
Nonacute Inpatient Stay 0 3
Organ Transplant Other Than Kidney 6 0
Other Drug Abuse and Dependence 1 0
Other Malignant Neoplasm of Skin 21 0
Other Neoplasms 12 1
Outpatient 1 0
Outpatient POS 0 2
Outpatient Without UBREV 1 0
Perinatal Conditions 33 0
Potentially Planned Procedures 46 0
Pregnancy 75 1
Pregnancy Diagnosis 57 1
Prenatal Visits 1 0
Pharyngitis 0 1
Rh 1 0
Rubella 0 1
Rubella Antibody 1 0
Sexual Activity 19 0
Spinal Infection 0 1
Toxoplasma Antibody 1 0
Trauma 1 1
Uncomplicated Low Back Pain 2 1
URI 0 1
Vaccine Causing Adverse Effect 1 1
Varicella Zoster 0 1
Well-Care 2 6
knitr::kable(  table( `Code System`, Change))
Added Deleted
CPT 16 9
CVX 2 0
ICD10CM 340 8678
ICD10PCS 52 0
ICD9CM 3 27
LOINC 14 13
POS 0 2
UBTOB 0 3
#knitr::kable(table(Change, `Revised`))


## "-----------------------------------"
df <- read_excel(xl , sheet = "Summary of Changes - Value Sets")
attach(df)
## The following objects are masked from df (pos = 3):
## 
##     Change, Revised
summary(df)
Value Set Name Change Description Revised
Length:63 Length:63 Length:63 Mode:logical
Class :character Class :character Class :character NA’s:63
Mode :character Mode :character Mode :character NA
names(df)
## [1] "Value Set Name" "Change"         "Description"    "Revised"
# [1] "Value Set Name" "Change"         "Description"    "Revised"
table(`Value Set Name`, Change)
Value Set Name/Change Added Deleted Renamed
Acute Condition 1 0 0
Acute Inpatient 1 0 0
ADD POS Group 1 0 1 0
ADD POS Group 2 0 1 0
ADD Stand Alone Visits 0 1 0
ADD Visits Group 1 0 1 0
ADD Visits Group 2 0 1 0
Advanced Illness 1 0 0
Ambulatory Surgical Center POS 1 0 0
AMM POS 0 1 0
AMM Stand Alone Visits 0 1 0
AMM Visits 0 1 0
AOD Medication Treatment 0 0 1
BH Outpatient 1 0 0
Bone Marrow Transplant 1 0 0
Community Mental Health Center POS 1 0 0
Chemotherapy 1 0 0
Diabetes 0 1 0
Diabetes Exclusions 0 1 0
Diastolic 80-89 1 0 0
Diastolic Greater Than/Equal To 90 1 0 0
Diastolic Less Than 80 1 0 0
ED 1 0 0
ED POS 1 0 0
Electroconvulsive Therapy 1 0 0
Encephalopathy Due To Vaccination 1 0 0
Frailty 1 0 0
FUH POS Group 1 0 1 0
FUH POS Group 2 0 1 0
FUH RevCodes Group 1 0 1 0
FUH RevCodes Group 2 0 1 0
FUH Stand Alone Visits 0 1 0
FUH Visits Group 1 0 1 0
FUH Visits Group 2 0 1 0
Health and Behavior Assessment/Intervention 1 0 0
Inpatient Stay 1 0 0
Intentional Self-Harm 1 0 0
Introduction of Autologous Pancreatic Cells 1 0 0
Kidney Transplant 1 0 0
Nonacute Inpatient 1 0 0
Nonacute Inpatient Stay 1 0 0
Observation 1 0 0
Observation Stay 1 0 0
Online Assessments 1 0 0
Organ Transplant Other Than Kidney 1 0 0
Outpatient 1 0 0
Outpatient POS 1 0 0
Partial Hospitalization POS 1 0 0
Partial Hospitalization/Intensive Outpatient 1 0 0
Perinatal Conditions 1 0 0
Potentially Planned Procedures 1 0 0
Pregnancy 1 0 0
Rehabilitation 1 0 0
Remote Blood Pressure Monitoring 1 0 0
Skilled Nursing Stay 1 0 0
Systolic Greater Than/Equal To 140 1 0 0
Systolic Less Than 140 1 0 0
Telehealth Modifier 1 0 0
Telehealth POS 1 0 0
Telephone Visits 1 0 0
Transcranial Magnetic Stimulation 1 0 0
Vaccine Causing Adverse Effect 1 0 0
Visit Setting Unspecified 1 0 0
table(`Description`, Change)
Description/Change Added Deleted Renamed
Added to: PCR2020 12 0 0
Added to: AAB, CBP, CDC, MMA 3 0 0
Added to: ADD 1 0 0
Added to: ADD, AMM, BCS, COL, FUH, IET, PCR2020 1 0 0
Added to: ADD, AMM, FUH 6 0 0
Added to: AMM 2 0 0
Added to: AMM, CDC, FUH, MMA 1 0 0
Added to: AMM, FUH 1 0 0
Added to: BCS, CBP, CDC, COL 2 0 0
Added to: BCS, COL, PCR2020 4 0 0
Added to: CBP 5 0 0
Added to: CBP, CDC 1 0 0
Added to: FUH 2 0 0
Added to: IMA 2 0 0
Added to: PCR2020 2 0 0
Deleted from: ADD 0 5 0
Deleted from: AMM 0 3 0
Deleted from: CBP 0 2 0
Deleted from: FUH 0 7 0
Formerly named: Medication Assisted Treatment 0 0 1
table(`Value Set Name`,`Revised`)
## Empty table
#"-----------------------------------"
df  <- read_excel(xl , sheet = "QRS Measures to Value Sets")
#View(med_meas)
attach(df)
## The following object is masked from df (pos = 3):
## 
##     Value Set Name
summary(df)
Measure ID Measure Name Value Set Name Value Set OID
Length:333 Length:333 Length:333 Length:333
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
names(df)
## [1] "Measure ID"     "Measure Name"   "Value Set Name" "Value Set OID"
# [1] "Measure ID"     "Measure Name"   "Value Set Name" "Value Set OID"
for (c in 1:ncol(df)) 
  #print(head(table(df[c])))
table(`Value Set Name`)
table(`Measure ID`)
AAB ABA ADD AMM BCS CBP CCS CDC CIS COL CWP CHL FUH GG IET IMA LBP MMA MPM PCR PCR2020 PPC URI W15 W34 WCC
19 4 15 16 18 24 3 30 24 14 6 6 17 3 17 7 22 16 5 17 18 18 7 1 1 5
table(`Measure Name`)
Adult BMI Assessment Annual Monitoring for Patients on Persistent Medications Antidepressant Medication Management Appropriate Testing for Children With Pharyngitis Appropriate Treatment for Children With Upper Respiratory Infection Avoidance of Antibiotic Treatment in Adults With Acute Bronchitis Breast Cancer Screening Cervical Cancer Screening Colorectal Cancer Screening Comprehensive Diabetes Care Controlling High Blood Pressure Childhood Immunization Status Chlamydia Screening in Women Follow-Up After Hospitalization for Mental Illuess Follow-Up Care for Children Prescribed ADHD Medication Identifying Events/Diagnoses Using Laboratory or Pharmacy Data Immunizations for Adolescents Initiation and Engagement of Alcohol and Other Drug Abuse or Dependence Treatment Medication Management for People With Asthma Members in Hospice Plan All-Cause Readmissions Plan All-Cause Readmissions 2020 Version Prenatal and Postpartum Care Use of Imaging Studies for Low Back Pain Weight Assessment and Counseling for Nutrition and Physical Activity for Children/Adolescents Well-Child Visits in the First 15 Months of Life Well-Child Visits in the Third, Fourth, Fifth and Sixth Years of Life
4 5 16 6 7 19 18 3 14 30 24 24 6 17 15 2 7 17 16 1 17 18 18 22 5 1 1
#"-----------------------------------"
df  <- read_excel(xl , sheet = "QRS Value Sets to Codes")
#View(med_code)
# rm(xl_rx)
attach(df)
## The following objects are masked from df (pos = 3):
## 
##     Value Set Name, Value Set OID
## The following object is masked from df (pos = 4):
## 
##     Value Set Name
## The following objects are masked from df (pos = 5):
## 
##     Code, Code System
summary(df)
Value Set Name Value Set OID Value Set Version Code Definition Code System Code System OID Code System Version
Length:91279 Length:91279 Length:91279 Length:91279 Length:91279 Length:91279 Length:91279 Length:91279
Class :character Class :character Class :character Class :character Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character Mode :character Mode :character Mode :character Mode :character
names(df)
## [1] "Value Set Name"      "Value Set OID"       "Value Set Version"  
## [4] "Code"                "Definition"          "Code System"        
## [7] "Code System OID"     "Code System Version"
# [1] "Value Set Name"      "Value Set OID"       "Value Set Version"   "Code"                "Definition"
# [6] "Code System"         "Code System OID"     "Code System Version"
for (c in 1:ncol(df)) 
  #print(head(table(df[c])))
table(`Value Set Name`)
table(`Code System`)
CPT CPT-CAT-II CVX HCPCS ICD10CM ICD10PCS ICD9CM ICD9PCS LOINC Modifier POS UBREV UBTOB
1327 25 44 326 66745 20629 976 55 507 9 54 377 205