*Purpose: This program creates the tables for the hospital staffing analysis using alternative ratios and different sets of hospitals. *Author: Martha Johnson *Date: 1/13/2020 ** Contents ** *1) Exclude H&H hospitals, original ratios *2) All hospitals, H&H ratios *3) Exclude H&H hospitals, H&H ratios *set directories global input "U:\NY Nurse Project\input" global output "U:\NY Nurse Project\output" ** 1) Exclude H&H hospitals, original ratios *load analysis data use "$input\hospital_data", clear *drop H&H hospitals drop if inlist(fac_facid,1165,1172,1186,1294,1301,1438) drop if inlist(fac_facid,1445,1454,1486,1626,1633,1692) ** Calculate nurse FTE needs from patient days. ** *1 patient per nurse foreach prefix in pediatric_surgical surgical_adult { gen `prefix'_need=`prefix'_pv*24/(31.5*50*1) } *2 patients per nurse foreach prefix in critical_care_adult critical_care_peds leveliiiiv_crit_care { gen `prefix'_need=`prefix'_pv*24/(31.5*50*2) } *3 patients per nurse foreach prefix in medical_peds peds_mixed_acuity medsurg_peds_combd /// stepdn_telemtry_peds step_dn_telemtry_adult adult_mixed_acuity /// other_ed neonate_mixed_acuity leveli_contg_care levelii_int obstetrics { gen `prefix'_need=`prefix'_pv*24/(31.5*50*3) } *4 patients per nurse foreach prefix in adult_psych adolescent_psych childadolest_psych child_psych medsurg_combd_adult medical_adult /// geropsych specialty_psych other_unit_type_psy behavl_healthchemicl multiple_unit_types { gen `prefix'_need=`prefix'_pv*24/(31.5*50*4) } *5 patients per nurse foreach prefix in adult_rehab pediatric_rehab rehab_ped_mixd_acuity rehab_mixd_acuity_ad skilled_nursing { gen `prefix'_need=`prefix'_pv*24/(31.5*50*5) } *6 patients per nurse foreach prefix in well_baby_nursery { gen `prefix'_need=`prefix'_pv*24/(31.5*50*6) } ** Calculate actual nurse FTEs from annual nursing patient-care hours ** *FTE nurses in each service unit foreach var of varlist *_nh { gen `var'_act=`var'/(31.5*50) } rename *_nh_act *_act ** Calculate gaps ** foreach prefix in adolescent_psych adult_mixed_acuity adult_psych adult_rehab behavl_healthchemicl child_psych childadolest_psych critical_care_adult critical_care_peds geropsych leveli_contg_care levelii_int leveliiiiv_crit_care medsurg_combd_adult medical_adult surgical_adult medical_peds medsurg_peds_combd multiple_unit_types neonate_mixed_acuity obstetrics other_ed other_unit_type_psy pediatric_rehab pediatric_surgical peds_mixed_acuity rehab_mixd_acuity_ad rehab_ped_mixd_acuity skilled_nursing specialty_psych step_dn_telemtry_adult stepdn_telemtry_peds well_baby_nursery { gen `prefix'_gap=max(0,`prefix'_need-`prefix'_act) } ** Estimate RN and LPN shares *sum nurse hours by nurse type egen hrs_all=rowtotal(*_rns *_lpns) egen hrs_rns=rowtotal(*_rns) egen hrs_lpns=rowtotal(*_lpns) egen hrs_uaps=rowtotal(*_uaps) *percentage of each position type gen pctrn=hrs_rns/hrs_all gen pctlpn=hrs_lpns/hrs_all *For two hospitals not reporting nurse hours, replace with average foreach type in rn lpn { sum pct`type' local avpct`type'=r(mean) replace pct`type'=`avpct`type'' if mi(pct`type') } *sum gaps across service units and multiply by rn and lpn percentages egen totgap=rowtotal(*gap) gen rnlpn_need=totgap gen rn_need=totgap*pctrn gen lpn_need=totgap*pctlpn ** Calculate total FTE nurses and patients *total FTE nurses across service units: egen tot_nh=rowtotal(*_nh) gen fte_nh=tot_nh/(31.5*50) gen fte_rns=fte_nh*pctrn gen fte_lpns=fte_nh*pctlpn *total patient FTEs across all service units egen tot_pv=rowtotal(*_pv) gen fte_pats=(tot_pv*24)/(31.5*50) ** Output data for report ** Table 1 ** collapse (count) reporters=beds (sum) beds rnlpn_need rn_need lpn_need fte_rns fte_lpns fte_pats, by(phipregion) *for appendix table, adjust FTE definition to 37.5 hours of patient care per week gen rn_need_app=rn_need*(31.5/37.5) gen lpn_need_app=lpn_need*(31.5/37.5) *label variables for table la var phipregion "Region" la var reporters "Reporters" la var beds "Certified beds" la var rnlpn_need "RN/LPN need" la var rn_need "RN need" la var lpn_need "LPN need" la var fte_rns "RNs" la var fte_lpns "LPNs" la var fte_pats "Patients" la var rn_need_app "RN need for appendix" la var lpn_need_app "LPN need for appendix" *export table export excel using "$output\Hospital_Tables", sheet("Table1_nonhh_hosp_orig_ratios", replace) firstrow(varlabels) ** Table 2 ** *drop unnecessary variables drop fte_pats rnlpn_need *_app *merge in wage data merge 1:1 phipregion using "$input\wages", keepusing(hosp_wage_rn hosp_wage_lpn) keep if _m==3 drop _m *adjust to 2019 dollars (1.055 is based on first 3 quarters of 2017 and 2019 employment cost index from BLS for health industries, series CIU1026200000000I (K)) foreach var of varlist *wage* { replace `var'=`var'*1.055 } *existing wage costs gen cost=hosp_wage_rn*fte_rns*36*52+hosp_wage_lpn*fte_lpns*36*52 sum cost local cost=r(sum) display `cost' *new wages, lower bound and upper bound foreach type in rn lpn { *lower bound gen wage_cost_old`type's_lb=fte_`type's*0.05*hosp_wage_`type'*36*52 gen wage_cost_new`type's_lb=`type'_need*1.05*hosp_wage_`type'*36*52 gen wage_cost_tot`type's_lb=wage_cost_old`type's_lb+wage_cost_new`type's_lb *upper bound gen wage_cost_old`type's_ub=fte_`type's*0.15*hosp_wage_`type'*36*52 gen wage_cost_new`type's_ub=`type'_need*1.15*hosp_wage_`type'*36*52 gen wage_cost_tot`type's_ub=wage_cost_old`type's_ub+wage_cost_new`type's_ub } *sum rn and lpn costs foreach type1 in old new tot { foreach type2 in lb ub { gen wage_cost_`type1'_`type2'=wage_cost_`type1'rns_`type2'+wage_cost_`type1'lpns_`type2' } } *for appendix table, adjust FTE definition to 37.5 hours of patient care per week and 40 hours paid per week gen wage_cost_tot_lb_app=wage_cost_tot_lb*(31.5/37.5)*(40/36) gen wage_cost_tot_ub_app=wage_cost_tot_ub*(31.5/37.5)*(40/36) *format format wage_cost* %15.0fc *sort sort phipregion *order keep phipregion wage_cost_old_lb wage_cost_old_ub wage_cost_new_lb wage_cost_new_ub wage_cost_tot_lb wage_cost_tot_ub wage_cost_tot_lb_app wage_cost_tot_ub_app order phipregion wage_cost_old_lb wage_cost_old_ub wage_cost_new_lb wage_cost_new_ub wage_cost_tot_lb wage_cost_tot_ub wage_cost_tot_lb_app wage_cost_tot_ub_app *label variables for table la var phipregion "Region" la var wage_cost_old_lb "Lower Bound Wage Cost Existing Nurses" la var wage_cost_new_lb "Lower Bound Wage Cost New Nurses" la var wage_cost_tot_lb "Lower Bound Wage Cost Total" la var wage_cost_old_ub "Upper Bound Wage Cost Existing Nurses" la var wage_cost_new_ub "Upper Bound Wage Cost New Nurses" la var wage_cost_tot_ub "Upper Bound Wage Cost Total" la var wage_cost_tot_lb_app "Lower Bound Wage Cost Total for Appendix" la var wage_cost_tot_ub_app "Upper Bound Wage Cost Total for Appendix" *export table export excel using "$output\Hospital_Tables", sheet("Table2_nonhh_hosp_orig_ratios", replace) firstrow(varlabels) ** 2) All hospitals, H&H ratios *load analysis data use "$input\hospital_data", clear ** Calculate nurse FTE needs from patient days. ** *1 patient per nurse foreach prefix in pediatric_surgical surgical_adult { gen `prefix'_need=`prefix'_pv*24/(31.5*50*1) } *2 patients per nurse foreach prefix in critical_care_adult critical_care_peds leveliiiiv_crit_care /// obstetrics { gen `prefix'_need=`prefix'_pv*24/(31.5*50*2) } *3 patients per nurse foreach prefix in neonate_mixed_acuity leveli_contg_care levelii_int { gen `prefix'_need=`prefix'_pv*24/(31.5*50*3) } *4 patients per nurse foreach prefix in step_dn_telemtry_adult stepdn_telemtry_peds { gen `prefix'_need=`prefix'_pv*24/(31.5*50*4) } *5 patients per nurse foreach prefix in other_ed { gen `prefix'_need=`prefix'_pv*24/(31.5*50*5) } *6 patients per nurse foreach prefix in skilled_nursing well_baby_nursery medsurg_combd_adult medical_adult /// medical_peds medsurg_peds_combd peds_mixed_acuity adult_mixed_acuity { gen `prefix'_need=`prefix'_pv*24/(31.5*50*6) } *7 patients per nurse foreach prefix in adult_rehab pediatric_rehab rehab_ped_mixd_acuity /// rehab_mixd_acuity_ad adult_psych adolescent_psych childadolest_psych /// child_psych geropsych specialty_psych other_unit_type_psy /// behavl_healthchemicl multiple_unit_types { gen `prefix'_need=`prefix'_pv*24/(31.5*50*7) } ** Calculate actual nurse FTEs from annual nursing patient-care hours ** *FTE nurses in each service unit foreach var of varlist *_nh { gen `var'_act=`var'/(31.5*50) } rename *_nh_act *_act ** Calculate gaps ** foreach prefix in adolescent_psych adult_mixed_acuity adult_psych adult_rehab behavl_healthchemicl child_psych childadolest_psych critical_care_adult critical_care_peds geropsych leveli_contg_care levelii_int leveliiiiv_crit_care medsurg_combd_adult medical_adult surgical_adult medical_peds medsurg_peds_combd multiple_unit_types neonate_mixed_acuity obstetrics other_ed other_unit_type_psy pediatric_rehab pediatric_surgical peds_mixed_acuity rehab_mixd_acuity_ad rehab_ped_mixd_acuity skilled_nursing specialty_psych step_dn_telemtry_adult stepdn_telemtry_peds well_baby_nursery { gen `prefix'_gap=max(0,`prefix'_need-`prefix'_act) } ** Estimate RN and LPN shares *sum nurse hours by nurse type egen hrs_all=rowtotal(*_rns *_lpns) egen hrs_rns=rowtotal(*_rns) egen hrs_lpns=rowtotal(*_lpns) egen hrs_uaps=rowtotal(*_uaps) *percentage of each position type gen pctrn=hrs_rns/hrs_all gen pctlpn=hrs_lpns/hrs_all *For two hospitals not reporting nurse hours, replace with average foreach type in rn lpn { sum pct`type' local avpct`type'=r(mean) replace pct`type'=`avpct`type'' if mi(pct`type') } *sum gaps across service units and multiply by rn and lpn percentages egen totgap=rowtotal(*gap) gen rnlpn_need=totgap gen rn_need=totgap*pctrn gen lpn_need=totgap*pctlpn ** Calculate total FTE nurses and patients *total FTE nurses across service units: egen tot_nh=rowtotal(*_nh) gen fte_nh=tot_nh/(31.5*50) gen fte_rns=fte_nh*pctrn gen fte_lpns=fte_nh*pctlpn *total patient FTEs across all service units egen tot_pv=rowtotal(*_pv) gen fte_pats=(tot_pv*24)/(31.5*50) ** Output data for report ** Table 1 ** collapse (count) reporters=beds (sum) beds rnlpn_need rn_need lpn_need fte_rns fte_lpns fte_pats, by(phipregion) *for appendix table, adjust FTE definition to 37.5 hours of patient care per week gen rn_need_app=rn_need*(31.5/37.5) gen lpn_need_app=lpn_need*(31.5/37.5) *label variables for table la var phipregion "Region" la var reporters "Reporters" la var beds "Certified beds" la var rnlpn_need "RN/LPN need" la var rn_need "RN need" la var lpn_need "LPN need" la var fte_rns "RNs" la var fte_lpns "LPNs" la var fte_pats "Patients" la var rn_need_app "RN need for appendix" la var lpn_need_app "LPN need for appendix" *export table export excel using "$output\Hospital_Tables", sheet("Table1_all_hosp_hh_ratios", replace) firstrow(varlabels) ** Table 2 ** *drop unnecessary variables drop fte_pats rnlpn_need *_app *merge in wage data merge 1:1 phipregion using "$input\wages", keepusing(hosp_wage_rn hosp_wage_lpn) keep if _m==3 drop _m *adjust to 2019 dollars (1.055 is based on first 3 quarters of 2017 and 2019 employment cost index from BLS for health industries, series CIU1026200000000I (K)) foreach var of varlist *wage* { replace `var'=`var'*1.055 } *existing wage costs gen cost=hosp_wage_rn*fte_rns*36*52+hosp_wage_lpn*fte_lpns*36*52 sum cost local cost=r(sum) display `cost' *new wages, lower bound and upper bound foreach type in rn lpn { *lower bound gen wage_cost_old`type's_lb=fte_`type's*0.05*hosp_wage_`type'*36*52 gen wage_cost_new`type's_lb=`type'_need*1.05*hosp_wage_`type'*36*52 gen wage_cost_tot`type's_lb=wage_cost_old`type's_lb+wage_cost_new`type's_lb *upper bound gen wage_cost_old`type's_ub=fte_`type's*0.15*hosp_wage_`type'*36*52 gen wage_cost_new`type's_ub=`type'_need*1.15*hosp_wage_`type'*36*52 gen wage_cost_tot`type's_ub=wage_cost_old`type's_ub+wage_cost_new`type's_ub } *sum rn and lpn costs foreach type1 in old new tot { foreach type2 in lb ub { gen wage_cost_`type1'_`type2'=wage_cost_`type1'rns_`type2'+wage_cost_`type1'lpns_`type2' } } *for appendix table, adjust FTE definition to 37.5 hours of patient care per week and 40 hours paid per week gen wage_cost_tot_lb_app=wage_cost_tot_lb*(31.5/37.5)*(40/36) gen wage_cost_tot_ub_app=wage_cost_tot_ub*(31.5/37.5)*(40/36) *format format wage_cost* %15.0fc *sort sort phipregion *order keep phipregion wage_cost_old_lb wage_cost_old_ub wage_cost_new_lb wage_cost_new_ub wage_cost_tot_lb wage_cost_tot_ub wage_cost_tot_lb_app wage_cost_tot_ub_app order phipregion wage_cost_old_lb wage_cost_old_ub wage_cost_new_lb wage_cost_new_ub wage_cost_tot_lb wage_cost_tot_ub wage_cost_tot_lb_app wage_cost_tot_ub_app *label variables for table la var phipregion "Region" la var wage_cost_old_lb "Lower Bound Wage Cost Existing Nurses" la var wage_cost_new_lb "Lower Bound Wage Cost New Nurses" la var wage_cost_tot_lb "Lower Bound Wage Cost Total" la var wage_cost_old_ub "Upper Bound Wage Cost Existing Nurses" la var wage_cost_new_ub "Upper Bound Wage Cost New Nurses" la var wage_cost_tot_ub "Upper Bound Wage Cost Total" la var wage_cost_tot_lb_app "Lower Bound Wage Cost Total for Appendix" la var wage_cost_tot_ub_app "Upper Bound Wage Cost Total for Appendix" *export table export excel using "$output\Hospital_Tables", sheet("Table2_all_hosp_hh_ratios", replace) firstrow(varlabels) ** 3) Exclude H&H hospitals, H&H ratios *load analysis data use "$input\hospital_data", clear *drop H&H hospitals drop if inlist(fac_facid,1165,1172,1186,1294,1301,1438) drop if inlist(fac_facid,1445,1454,1486,1626,1633,1692) ** Calculate nurse FTE needs from patient days. ** *1 patient per nurse foreach prefix in pediatric_surgical surgical_adult { gen `prefix'_need=`prefix'_pv*24/(31.5*50*1) } *2 patients per nurse foreach prefix in critical_care_adult critical_care_peds leveliiiiv_crit_care /// obstetrics { gen `prefix'_need=`prefix'_pv*24/(31.5*50*2) } *3 patients per nurse foreach prefix in neonate_mixed_acuity leveli_contg_care levelii_int { gen `prefix'_need=`prefix'_pv*24/(31.5*50*3) } *4 patients per nurse foreach prefix in step_dn_telemtry_adult stepdn_telemtry_peds { gen `prefix'_need=`prefix'_pv*24/(31.5*50*4) } *5 patients per nurse foreach prefix in other_ed { gen `prefix'_need=`prefix'_pv*24/(31.5*50*5) } *6 patients per nurse foreach prefix in skilled_nursing well_baby_nursery medsurg_combd_adult medical_adult /// medical_peds medsurg_peds_combd peds_mixed_acuity adult_mixed_acuity { gen `prefix'_need=`prefix'_pv*24/(31.5*50*6) } *7 patients per nurse foreach prefix in adult_rehab pediatric_rehab rehab_ped_mixd_acuity /// rehab_mixd_acuity_ad adult_psych adolescent_psych childadolest_psych /// child_psych geropsych specialty_psych other_unit_type_psy /// behavl_healthchemicl multiple_unit_types { gen `prefix'_need=`prefix'_pv*24/(31.5*50*7) } ** Calculate actual nurse FTEs from annual nursing patient-care hours ** *FTE nurses in each service unit foreach var of varlist *_nh { gen `var'_act=`var'/(31.5*50) } rename *_nh_act *_act ** Calculate gaps ** foreach prefix in adolescent_psych adult_mixed_acuity adult_psych adult_rehab behavl_healthchemicl child_psych childadolest_psych critical_care_adult critical_care_peds geropsych leveli_contg_care levelii_int leveliiiiv_crit_care medsurg_combd_adult medical_adult surgical_adult medical_peds medsurg_peds_combd multiple_unit_types neonate_mixed_acuity obstetrics other_ed other_unit_type_psy pediatric_rehab pediatric_surgical peds_mixed_acuity rehab_mixd_acuity_ad rehab_ped_mixd_acuity skilled_nursing specialty_psych step_dn_telemtry_adult stepdn_telemtry_peds well_baby_nursery { gen `prefix'_gap=max(0,`prefix'_need-`prefix'_act) } ** Estimate RN and LPN shares *sum nurse hours by nurse type egen hrs_all=rowtotal(*_rns *_lpns) egen hrs_rns=rowtotal(*_rns) egen hrs_lpns=rowtotal(*_lpns) egen hrs_uaps=rowtotal(*_uaps) *percentage of each position type gen pctrn=hrs_rns/hrs_all gen pctlpn=hrs_lpns/hrs_all *For two hospitals not reporting nurse hours, replace with average foreach type in rn lpn { sum pct`type' local avpct`type'=r(mean) replace pct`type'=`avpct`type'' if mi(pct`type') } *sum gaps across service units and multiply by rn and lpn percentages egen totgap=rowtotal(*gap) gen rnlpn_need=totgap gen rn_need=totgap*pctrn gen lpn_need=totgap*pctlpn ** Calculate total FTE nurses and patients *total FTE nurses across service units: egen tot_nh=rowtotal(*_nh) gen fte_nh=tot_nh/(31.5*50) gen fte_rns=fte_nh*pctrn gen fte_lpns=fte_nh*pctlpn *total patient FTEs across all service units egen tot_pv=rowtotal(*_pv) gen fte_pats=(tot_pv*24)/(31.5*50) ** Output data for report ** Table 1 ** collapse (count) reporters=beds (sum) beds rnlpn_need rn_need lpn_need fte_rns fte_lpns fte_pats, by(phipregion) *for appendix table, adjust FTE definition to 37.5 hours of patient care per week gen rn_need_app=rn_need*(31.5/37.5) gen lpn_need_app=lpn_need*(31.5/37.5) *label variables for table la var phipregion "Region" la var reporters "Reporters" la var beds "Certified beds" la var rnlpn_need "RN/LPN need" la var rn_need "RN need" la var lpn_need "LPN need" la var fte_rns "RNs" la var fte_lpns "LPNs" la var fte_pats "Patients" la var rn_need_app "RN need for appendix" la var lpn_need_app "LPN need for appendix" *export table export excel using "$output\Hospital_Tables", sheet("Table1_nonhh_hosp_hh_ratios", replace) firstrow(varlabels) ** Table 2 ** *drop unnecessary variables drop fte_pats rnlpn_need *_app *merge in wage data merge 1:1 phipregion using "$input\wages", keepusing(hosp_wage_rn hosp_wage_lpn) keep if _m==3 drop _m *adjust to 2019 dollars (1.055 is based on first 3 quarters of 2017 and 2019 employment cost index from BLS for health industries, series CIU1026200000000I (K)) foreach var of varlist *wage* { replace `var'=`var'*1.055 } *existing wage costs gen cost=hosp_wage_rn*fte_rns*36*52+hosp_wage_lpn*fte_lpns*36*52 sum cost local cost=r(sum) display `cost' *new wages, lower bound and upper bound foreach type in rn lpn { *lower bound gen wage_cost_old`type's_lb=fte_`type's*0.05*hosp_wage_`type'*36*52 gen wage_cost_new`type's_lb=`type'_need*1.05*hosp_wage_`type'*36*52 gen wage_cost_tot`type's_lb=wage_cost_old`type's_lb+wage_cost_new`type's_lb *upper bound gen wage_cost_old`type's_ub=fte_`type's*0.15*hosp_wage_`type'*36*52 gen wage_cost_new`type's_ub=`type'_need*1.15*hosp_wage_`type'*36*52 gen wage_cost_tot`type's_ub=wage_cost_old`type's_ub+wage_cost_new`type's_ub } *sum rn and lpn costs foreach type1 in old new tot { foreach type2 in lb ub { gen wage_cost_`type1'_`type2'=wage_cost_`type1'rns_`type2'+wage_cost_`type1'lpns_`type2' } } *for appendix table, adjust FTE definition to 37.5 hours of patient care per week and 40 hours paid per week gen wage_cost_tot_lb_app=wage_cost_tot_lb*(31.5/37.5)*(40/36) gen wage_cost_tot_ub_app=wage_cost_tot_ub*(31.5/37.5)*(40/36) *format format wage_cost* %15.0fc *sort sort phipregion *order keep phipregion wage_cost_old_lb wage_cost_old_ub wage_cost_new_lb wage_cost_new_ub wage_cost_tot_lb wage_cost_tot_ub wage_cost_tot_lb_app wage_cost_tot_ub_app order phipregion wage_cost_old_lb wage_cost_old_ub wage_cost_new_lb wage_cost_new_ub wage_cost_tot_lb wage_cost_tot_ub wage_cost_tot_lb_app wage_cost_tot_ub_app *label variables for table la var phipregion "Region" la var wage_cost_old_lb "Lower Bound Wage Cost Existing Nurses" la var wage_cost_new_lb "Lower Bound Wage Cost New Nurses" la var wage_cost_tot_lb "Lower Bound Wage Cost Total" la var wage_cost_old_ub "Upper Bound Wage Cost Existing Nurses" la var wage_cost_new_ub "Upper Bound Wage Cost New Nurses" la var wage_cost_tot_ub "Upper Bound Wage Cost Total" la var wage_cost_tot_lb_app "Lower Bound Wage Cost Total for Appendix" la var wage_cost_tot_ub_app "Upper Bound Wage Cost Total for Appendix" *export table export excel using "$output\Hospital_Tables", sheet("Table2_nonhh_hosp_hh_ratios", replace) firstrow(varlabels)