*************************************************************** * 30 May 2000: Input 1997/98 In-Patient Admissions to * the 7 Winnipeg Hospitals (HSC, StB., 7 Oaks, Concordia, Grace, * Victoria, Misericordia) (Data came from the COMPLETE 97/98 & 98/99 * MCHPE hospital claims datasets. * Count # of patients in hosp. each night for 1 yr starting at * 31 March 97. Save data in quote-comma file. Compare Census & * Admissions counts each week with the results obtained when using * data from complete 97/98 + complete 98/99 hospital claims (i.e. * refer to census.drgsm.9798F.sas) * NOTE: this program uses complete 97/98 hospital claims + First Quarter 98/99 claims. * Author: Leonard MacWilliam ***************************************************************; OPTIONS nocenter IMPLMAC ; %include '/project/seasonal_use/prog/leonard/drg13sm.fmt' ; %include '/project/seasonal_use/prog/leonard/drg11sm.fmt' ; %include '/project/seasonal_use/prog/leonard/drg9sm.fmt' ; Proc Format ; value hospl 23 = '01.Health Sciences Centre' 12 = '02.St. Boniface Hospital' 16 = '04.Concordia Hospital' 11 = '05.Misericordia Hospital' 10 = '06.Grace General Hospital' 18 = '07.Seven Oaks General' 14 = '08.Victoria General' ; value $adstatl '1','2' = 'Emerg/Urgent' '3' = 'Elective' '4' = 'Day Care' '5' = 'Still B.' '6' = 'Brain Dead' ; value $drgl '1'='Surgical' '2'='Medical ' '3'='Obstet. ' '4'='Psych. ' '6'='Other ' ; value $type '1' = 'Emerg. MEDICAL' '2'= 'Sched. SURG' '3'= 'All Obstet.' '4'= 'Sched. MED.' '5'= 'Emerg SURG' '6'= 'All Psych.' '8'= 'Day Surg.' '9'= 'Sched+Day Surg' ; run ; libname seas '/project/seasonal_use/data/'; Data test ; set seas.in9297(KEEP=admdate dateadm a_wk_Wed s_wk_wed sepdate datesep phin hosp adstat drg g7r11drg g9r13drg adstat entrycd op01 dx01 los sameday ageadm) seas.in9798(KEEP=admdate dateadm a_wk_Wed s_wk_wed sepdate datesep los phin hosp adstat g9r13drg adstat entrycd op01 dx01 sameday ageadm) ; *** if 400000 < _N_ < 400200 ; ** use for testing the program **; *** Set ENTRYCD=0 to missing ***; if entrycd='0' then entrycd=' '; if drg ne ' ' then do; drgtmp=drg; drgsm = put(input(drg,3.),drg9smf.); end; Else if g7r11drg ne ' ' then do; drgtmp=g7r11drg; drgsm = put(input(g7r11drg,3.),drg11smf.); End ; Else if g9r13drg ne ' ' then do; drgtmp=g9r13drg; drgsm = put(input(g9r13drg,3.),drg13smf.); end; *** Apply fix to Other cases; if drgtmp in ('468','470') then do; if op01 = ' ' then drgsm='2'; * Assign cases without OP01 to Medical; else if op01 ^= ' ' then drgsm='1'; * Assign cases with OP01 to Surgical; else drgsm = ' ' ; end; ** create a variable with the various types of service ***; servtyp = ' ' ; If (385 <= (input(drgtmp,3.)) <= 391) & ageadm=0 & adstat='3' then servtyp = '7' ; * newborns *; Else If drgsm = '2' & adstat in ('1','2') then servtyp = '1' ; *** Emerg/Urgent Medical **; Else If drgsm = '1' & adstat in ('3') then servtyp = '2' ; *** Scheduled Surgery **; Else If drgsm in ('3') then servtyp = '3' ; ** all Obstetrics *; Else If drgsm = '2' & adstat in ('3') then servtyp = '4' ; *** Scheduled Medical **; Else If drgsm = '1' & adstat in ('1','2') then servtyp = '5' ; *** Emerg/Urgent Surgery **; Else If drgsm in ('4') then servtyp = '6' ; ** all Psychiatry *; ** GROUP ALL MEDICAL & ALL SURGICAL ***; If servtyp in ('1','3','4','6') then servis = 'Medical' ; Else If servtyp in ('2','5') then servis = 'Surgery' ; Else servis = '' ; run ; proc sort data=test out=test NODUPKEY ; by phin hosp adstat admdate sepdate ; run ; Data test ; set test(drop=phin) ; ** Count # of patients in a bed each night by counting patients with... * admission date before a given date (eg. April 1) and separation date... * after the given date PLUS patients with admission date on the given * date. ALSO, patients with admission date = separation date are NOT ... * counted, since they did not occupy a bed over night. ************************; LENGTH schmed urgmed obstet psych schsurg urgsurg newbrn 4 ; RETAIN schmed urgmed obstet psych schsurg urgsurg newbrn 0 ; ** set initial values to 0 **; **NEXT: get CENSUS for 31 March 1997 ****; **If (admdate < 13973) & (sepdate > 13603) & SAMEDAY = 'N' then DO ; If (sepdate > 13604) & SAMEDAY = 'N' then DO ; IF servtyp = '1' then Do ; *COUNT EMERG/URGENT MEDICAL PATIENTS*; ** NOTE: SAS DATE 13606 is 31 March 1997 *******; If (admdate <= (13606) ) & (sepdate > (13606) ) then urgmed = urgmed + 1 ; End ; ** END IF SERVTYP = 1 **; ELSE IF servtyp = '2' then Do ; *COUNT Scheduled Surgical PATIENTS*; ** NOTE: SAS DATE 13604 is 31 March 1997 *******; If (admdate <= (13604) ) & (sepdate > (13604) ) then schsurg = schsurg + 1 ; End ; ** END IF SERVTYP = 2 **; ELSE IF servtyp = '3' then Do ; *COUNT Obstet PATIENTS*; ** NOTE: SAS DATE 13604 is 31 March 1997 *******; If (admdate <= (13604) ) & (sepdate > (13604) ) then obstet = obstet + 1 ; End ; ** END IF SERVTYP = 3 **; ELSE IF servtyp = '4' then Do ; *COUNT SCHEDULED MEDICAL PATIENTS*; ** NOTE: SAS DATE 13604 is 31 March 1997 *******; If (admdate <= (13604) ) & (sepdate > (13604) ) then schmed = schmed + 1 ; End ; ** END IF SERVTYP = 4 **; ELSE IF servtyp = '5' then Do ; *COUNT EMERG/URGENT SURGICAL PATIENTS*; ** NOTE: SAS DATE 13604 is 31 March 1997 *******; If (admdate <= (13604) ) & (sepdate > (13604) ) then urgsurg = urgsurg + 1 ; End ; ** END IF SERVTYP = 5 **; ELSE IF servtyp = '6' then Do ; *COUNT Pschy PATIENTS*; ** NOTE: SAS DATE 13604 is 31 March 1997 *******; If (admdate <= (13604) ) & (sepdate > (13604) ) then psych = psych + 1 ; End ; ** END IF SERVTYP = 6 **; ELSE IF servtyp = '7' then Do ; *COUNT newborn PATIENTS*; ** NOTE: SAS DATE 13604 is 31 March 1997 *******; If (admdate <= (13604) ) & (sepdate > (13604) ) then newbrn = newbrn + 1 ; End ; ** END IF SERVTYP = 7 **; ***END TEMP OMIT ***/; END ; ** END IF ADMDATE<13973 & ... ***; run ; Data last ; set test end=last ; if last then output last ; run ; Proc Print data=last(obs=1) ; var urgmed schmed urgsurg schsurg obstet psych newbrn ; title 'Data Set LAST - patient counts by DRGSM for 2 Apr 97 -8 Apr 97' ; footnote ; run ; ** NEXT: count the data by separation date & admission date 97/98 **; Proc Freq data=test ; where ('970331' < put(sepdate,yymmdd6.) <= '980331') ; Tables servtyp*sepdate / out=stest noprint ; run ; Proc Freq data=test ; where ('970331' < put(admdate,yymmdd6.) <= '980331') ; Tables servtyp*admdate*a_wk_wed / out=atest noprint ; run ; Data test1 test2 test3 test4 test5 test6 test7 ; merge atest(rename=(admdate=date count=admiss)) stest(rename=(sepdate=date count=sep)) ; by servtyp date ; if servtyp in ('1','2','3','4','5','6','7') ; If sep = . then sep = 0 ; If admiss = . then admiss = 0 ; EXCESS = admiss - sep ; month = put(date,worddate3.) ; year = substr(a_wk_wed,1,5) ; ** separate the fiscal yr/week ...*; week = substr(a_wk_wed,7,2) ; **... into a year & a week var. *; if servtyp = '1' then output test1 ; else if servtyp = '2' then output test2 ; else if servtyp = '3' then output test3 ; else if servtyp = '4' then output test4 ; else if servtyp = '5' then output test5 ; else if servtyp = '6' then output test6 ; else output test7 ; run ; Data test1 ; ** Start with THE COUNT ON 31 March _C **; set test1 ; ** set patient count on 31 March _C to what it was ** computed in above data step ***; retain urgmed_C 923 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; urgmed_C = urgmed_C + excess ; run ; Data test2 ; ** THE COUNT ON 31 March _C **; set test2 ; ** set patient count on 31 March _C to what it was ** computed in the above data step) ***; retain schsrg_C 147 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; schsrg_C = schsrg_C + excess ; run ; Data test3 ; ** THE COUNT ON 31 March _C **; set test3 ; ** set patient count on 31 March _C to what it was ** computed in the above data step) ***; retain obstet_C 90 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; obstet_C = obstet_C + excess ; run ; Data test4 ; ** Start with THE COUNT ON 31 March _C **; set test4 ; ** set patient count on 31 March _C to what it was ** computed in above data step ***; retain schmed_C 57 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; schmed_C = schmed_C + excess ; run ; Data test5 ; ** THE COUNT ON 31 March _C **; set test5 ; ** set patient count on 31 March _C to what it was ** computed in the above data step) ***; retain urgsrg_C 428 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; urgsrg_C = urgsrg_C + excess ; run ; Data test6 ; ** THE COUNT ON 31 March 97 **; set test6 ; ** set patient count on 31 March 97 to what it was ** computed in the above data step) ***; retain psych_C 323 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; psych_C = psych_C + excess ; run ; Data test7 ; ** THE COUNT ON 31 March _C **; set test7 ; ** set patient count on 31 March _C to what it was ** computed in the above data step) ***; retain newbrn_C 88 ; ** Next: add to the count on 31 March each day s difference between ... ** admissions & discharges. ***; newbrn_C = newbrn_C + excess ; run ; Data yr9798 ; merge test1(drop=servtyp sep rename=(admiss=urgmed_A excess=urgmedx)) test2(drop=servtyp sep rename=(admiss=schsrg_A excess=schsrgx)) test3(drop=servtyp sep rename=(admiss=obstet_A excess=obstetx)) test4(drop=servtyp sep rename=(admiss=schmed_A excess=schmedx)) test5(drop=servtyp sep rename=(admiss=urgsrg_A excess=urgsrgx)) test6(drop=servtyp sep rename=(admiss=psych_A excess=psychx)) test7(drop=servtyp sep rename=(admiss=newbrn_A excess=newbrnx)) ; by date ; ** If on any given day there were no admissions and no discharges ** for a type of service then this MERGE will generate missing ** values for the admission count, excess & census count. The ** following IF ... THEN statements will set missing admission ** & excess counts to 0 and the census count to what it was the ** previous day. ** 30 Sept 98 : this problem exists only for psych & sch. med. *; lastpsy = lag1(psych_C) ; lastsmd = lag1(schmed_C) ; IF psych_A = . & psychx = . then do ; psych_A = 0 ; psychx = 0 ; psych_C = lastpsy ; End ; IF schmed_A = . & schmedx = . then do ; schmed_A = 0 ; schmedx = 0 ; schmed_C = lastsmd ; End ; DROP lastpsy lastsmd ; label schsrg_C = 'Sched. Surgical' urgmed_C = 'Emerg/Urg Medical' urgsrg_C = 'Emerg/Urg Surgical' schmed_C = 'Sched. Medical' obstet_C = 'Obstetrics' psych_C = 'Psychiatry' newbrn_C = 'NewBorns' schsrg_A = 'Sched. Surgical-Admiss' urgmed_A = 'Emerg/Urg Medical-Admiss' urgsrg_A = 'Emerg/Urg Surgical-Admiss' schmed_A = 'Sched. Medical-Admiss' obstet_A = 'Obstetrics-Admiss' psych_A = 'Psychiatry-Admiss' newbrn_A = 'Newborns-Admiss' urgmedx = 'Excess:Urg.Med.' schsrgx = 'Excess:Sched.Surg.' schmedx = 'Excess:Sched.Med.' urgsrgx = 'Excess:Urg.Surg.' obstetx = 'Excess:Obstet.' psychx = 'Excess:Psych.' newbrnx = 'Excess:NewBorns' ; DROP percent ; run ; Proc Print data=yr9798 label ; title 'Daily Census -Medical & Surgical- All Wpg. Hospitals'; title2 'Over a 1 Yr Period - Starting 1 April 1997' ; title3 'Patient Counts are from the Hospital Data itself' ; title4 'The ENTIRE 98/99 Hospital claims rather than just the 1st Quarter 98/99'; run ; /*** output the appropriate data to a quote-comma file **; _lotus input=yr9798 output="/dsd1/project/seasonal_use/data/day.cens9798.drgsm.txt" label=label comment="Daily CENSUS-Medical & Surgical- All Wpg. Hospitals. 97/98." ; run ; **********/; ** Compute weekly averages and save in quote-comma file *****; Proc Means Data=yr9798 MEAN NWAY NOPRINT ; class year week ; var urgmed_C urgmed_A urgmedx schmed_C schmed_A schmedx urgsrg_C urgsrg_A urgsrgx obstet_C obstet_A obstetx schsrg_C schsrg_A schsrgx newbrn_C newbrn_A newbrnx psych_C psych_A psychx ; id month ; output out=week(drop=_freq_ _type_) mean= ; title 'Weekly (Wed. to Tues.) CENSUS -Medical & Surgical- All Wpg. Hospitals'; title2 'Over a 1 Yr Period - Starting Wed. 1 April 1987' ; title3 'Patient Counts are from the Hospital Data itself' ; run ; *** round all averages to a single decimal place **; Data week ; set week ; urgmed_c = round(urgmed_c,.1) ; urgsrg_c = round(urgsrg_c,.1) ; schmed_c = round(schmed_c,.1) ; schsrg_c = round(schsrg_c,.1) ; obstet_c = round(obstet_c,.1) ; psych_c = round(psych_c,.1) ; newbrn_c = round(newbrn_c,.1) ; urgmed_a = round(urgmed_a,.1) ; urgsrg_a = round(urgsrg_a,.1) ; schmed_a = round(schmed_a,.1) ; schsrg_a = round(schsrg_a,.1) ; obstet_a = round(obstet_a,.1) ; psych_a = round(psych_a,.1) ; newbrn_a = round(newbrn_a,.1) ; urgmedx = round(urgmedx,.1) ; urgsrgx = round(urgsrgx,.1) ; schmedx = round(schmedx,.1) ; schsrgx = round(schsrgx,.1) ; obstetx = round(obstetx,.1) ; psychx = round(psychx,.1) ; newbrnx = round(newbrnx,.1) ; run ; *** output the appropriate data to a quote-comma file **; _lotus input=week output="/project/seasonal_use/data/weekavg.cens97Q.drgsm.csv" label=label lrecl=580 comment="Avg. Daily Census per WEEK. BY DRGSM. Wpg. Hospitals. 97/98 (1st Quarter 98/99)." ; run ; ********* THE END *****/;