source: WorldVistAEHR/trunk/r/HOSPITAL_BASED_HOME_CARE-HBH/HBHCRP23.m@ 1800

Last change on this file since 1800 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.7 KB
Line 
1HBHCRP23 ; LR VAMC(IRMS)/MJT-HBHC report on file 631, Patient Days by date range, sorted by patient name, includes: IEN, patient name, Last Four, admission date, discharge date, & pt days w/totals ; 12/21/05 3:31pm
2 ;;1.0;HOSPITAL BASED HOME CARE;**21,22**;NOV 01, 1993;Build 2
3 ; Notes: date range should be inclusion of all days; D/C date is not included in patient day count
4 D START^HBHCUTL
5 G:(HBHCBEG1=-1)!(HBHCEND1=-1) EXIT
6 S %ZIS="Q",HBHCCC=0 K IOP,ZTIO,ZTSAVE D ^%ZIS G:POP EXIT
7 I $D(IO("Q")) S ZTRTN="DQ^HBHCRP23",ZTDESC="HBPC Patient Days of Care by Date Range Report",ZTSAVE("HBHC*")="" D ^%ZTLOAD G EXIT
8DQ ; De-queue
9 U IO
10 K ^TMP("HBHC",$J)
11 S $P(HBHCY,"-",81)="",HBHCHEAD="Patient Days of Care by Date Range",HBHCHDR="W !?63,""Discharge"",?73,""Patient"",!,""IEN"",?7,""Patient Name"",?34,""Last Four"",?50,""Date"",?63,""Date"",?73,""Days""",(HBHCCNT,HBHCCNT1,HBHCTOT,HBHCTOT1)=0
12 S HBHCCOLM=(80-(30+$L(HBHCHEAD))\2) S:HBHCCOLM'>0 HBHCCOLM=1
13 D TODAY^HBHCUTL D:IO'=IO(0)!($D(IO("S"))) HDRRANGE^HBHCUTL
14 I '$D(IO("S")),(IO=IO(0)) S HBHCCC=HBHCCC+1 D HDRRANGE^HBHCUTL
15LOOP ; Loop thru ^HBHC(631) "AD" (admission date) cross-ref to build report
16 S HBHCADDT=0 F S HBHCADDT=$O(^HBHC(631,"AD",HBHCADDT)) Q:(HBHCADDT'>0)!(HBHCADDT>HBHCEND1) S HBHCDFN="" F S HBHCDFN=$O(^HBHC(631,"AD",HBHCADDT,HBHCDFN)) Q:HBHCDFN="" S HBHCNOD0=^HBHC(631,HBHCDFN,0) D:$P(HBHCNOD0,U,15)=1 PROCESS
17 D PRTLOOP
18 I ($D(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<14) W @IOF D HDRRANGE^HBHCUTL
19 W !!,HBHCZ,!?14,">>> Date Range: ",HBHCBEG2," to ",HBHCEND2," <<<"
20 W !,HBHCZ,!,"Total Active Patients: ",$J($FN((HBHCCNT-HBHCCNT1),","),6)
21 W !,HBHCZ,!,"Complete Episodes of Care Only:",!?4,"Total Patients: ",$J($FN(HBHCCNT1,","),6)," Total Patient Days in Date Range: ",$J($FN(HBHCTOT1,","),10)
22 W !,HBHCZ,!?4,"Total Patients: ",$J($FN(HBHCCNT,","),6)," Total Patient Days in Date Range: ",$J($FN(HBHCTOT,","),10),!,HBHCZ
23 D ENDRPT^HBHCUTL1
24EXIT ; Exit module
25 D ^%ZISC
26 K HBHCADDT,HBHCBEG1,HBHCBEG2,HBHCCOLM,HBHCCC,HBHCCNT,HBHCCNT1,HBHCDATE,HBHCDFN,HBHCDPT0,HBHCDSDT,HBHCEND1,HBHCEND2,HBHCHDR,HBHCHEAD,HBHCLOS,HBHCNAME,HBHCNOD0,HBHCPAGE,HBHCTDY,HBHCTMP,HBHCTOT,HBHCTOT1,HBHCY,HBHCZ,X,X1,X2
27 K Y,^TMP("HBHC",$J)
28 Q
29PROCESS ; Process record & build ^TMP("HBHC",$J) global
30 S HBHCDSDT=$P(HBHCNOD0,U,40)
31 ; Add 1 to ending date to handle date range being inclusive
32 S X1=HBHCEND1,X2=1 D C^%DTC S HBHCDATE=X
33 ; '> below handles Discharge Date being same as date range beginning date
34 I HBHCDSDT]"" Q:(HBHCDSDT'>HBHCBEG1) I HBHCEND1>HBHCDSDT S HBHCDATE=HBHCDSDT
35 S HBHCDPT0=^DPT($P(HBHCNOD0,U),0),HBHCLOS="",HBHCCNT=HBHCCNT+1
36 S HBHCDAT=$S(HBHCADDT>HBHCBEG1:HBHCADDT,1:HBHCBEG1)
37 S X1=HBHCDATE,X2=HBHCDAT
38 D ^%DTC S HBHCLOS=X
39 ; handles Admission Date being same as date range ending date, OR Adm & D/C dates being equal
40 S:HBHCLOS=0 HBHCLOS=1
41 S HBHCTOT=HBHCTOT+HBHCLOS
42 ; '> below handles counting as complete episode of care ONLY if Discharge Date is within date range
43 S:(HBHCDSDT]"")&(HBHCDSDT'>HBHCEND1) HBHCCNT1=HBHCCNT1+1,HBHCTOT1=HBHCTOT1+HBHCLOS
44 S HBHCDSDT=$S(HBHCDSDT]"":$E(HBHCDSDT,4,5)_"-"_$E(HBHCDSDT,6,7)_"-"_$E(HBHCDSDT,2,3),1:"")
45 S ^TMP("HBHC",$J,$P(HBHCDPT0,U),HBHCADDT)=$E($P(HBHCDPT0,U,9),6,9)_U_HBHCDSDT_U_HBHCLOS_U_HBHCDFN
46 Q
47PRTLOOP ; Print loop
48 S HBHCNAME="" F S HBHCNAME=$O(^TMP("HBHC",$J,HBHCNAME)) Q:HBHCNAME="" S HBHCADDT="" F S HBHCADDT=$O(^TMP("HBHC",$J,HBHCNAME,HBHCADDT)) Q:HBHCADDT="" D PRINT
49 Q
50PRINT ; Print report
51 I ($D(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<5) W @IOF D HDRRANGE^HBHCUTL
52 S HBHCTMP=^TMP("HBHC",$J,HBHCNAME,HBHCADDT)
53 I $P(HBHCTMP,U,3)>0 W !,$J("`"_$P(HBHCTMP,U,4),5)_" "_$E(HBHCNAME,1,24),?34,$P(HBHCTMP,U),?50,$E(HBHCADDT,4,5)_"-"_$E(HBHCADDT,6,7)_"-"_$E(HBHCADDT,2,3),?63,$P(HBHCTMP,U,2),?76,$J($P(HBHCTMP,U,3),4),!,HBHCY
54 Q
Note: See TracBrowser for help on using the repository browser.