HBHCRP10 ; LR VAMC(IRMS)/MJT-HBHC report on file 631, All active (admitted but not discharged) cases by date range, sorted by patient name, includes: patient name, Last Four, admission date, & total ; 12/21/05 3:31pm
;;1.0;HOSPITAL BASED HOME CARE;**6,22,24**;NOV 01, 1993;Build 201
D START^HBHCUTL
G:(HBHCBEG1=-1)!(HBHCEND1=-1) EXIT
W ! D MFHS^HBHCUTL3 D:$D(HBHCMFHS) MFH^HBHCUTL3
G:$D(DIRUT) EXIT
S %ZIS="Q",HBHCCC=0 K IOP,ZTIO,ZTSAVE D ^%ZIS G:POP EXIT
I $D(IO("Q")) S ZTRTN="DQ^HBHCRP10",ZTDESC="HBPC Program Census Report",ZTSAVE("HBHC*")="" D ^%ZTLOAD G EXIT
DQ ; De-queue
U IO
S HBHCTOT=0,$P(HBHCY,"-",81)="",HBHCHEAD="Program Census"
; HBHCMFHS variable set in MFHS^HBHCUTL3
S:'$D(HBHCMFHS) HBHCHDR="W !,""Patient Name"",?43,""Last Four"",?68,""Date"""
S:$D(HBHCMFHS) HBHCHDR="W !,?33,""Last"",!,""Patient Name"",?33,""Four"",?40,""Date"",?55,""Medical Foster Name Name"""
; HBHCMFHR variable set in MFH^HBHCUTL3
S:$D(HBHCMFHR) HBHCHEAD="Medical Foster Home (MFH) "_HBHCHEAD
S HBHCCOLM=(80-(30+$L(HBHCHEAD))\2) S:HBHCCOLM'>0 HBHCCOLM=1
D TODAY^HBHCUTL D:IO'=IO(0)!($D(IO("S"))) HDRRANGE^HBHCUTL
I '$D(IO("S")),(IO=IO(0)) S HBHCCC=HBHCCC+1 D HDRRANGE^HBHCUTL
LOOP ; Loop thru ^HBHC(631) "AD" (admission date) cross-ref to build report
S X1=HBHCBEG1,X2=-1 D C^%DTC S HBHCADDT=X
F S HBHCADDT=$O(^HBHC(631,"AD",HBHCADDT)) Q:(HBHCADDT="")!(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
W:'$D(^TMP("HBHC",$J)) !!,"No data found for Date Range selected."
I $D(^TMP("HBHC",$J)) D PRTLOOP W !!,HBHCZ,!,"Program Census Total: ",HBHCTOT,!,HBHCZ
D ENDRPT^HBHCUTL1
EXIT ; Exit module
D ^%ZISC
K DIR,HBHCADDT,HBHCBEG1,HBHCBEG2,HBHCCOLM,HBHCCC,HBHCDFN,HBHCDPT0,HBHCEND1,HBHCEND2,HBHCHDR,HBHCHEAD,HBHCMFHN,HBHCMFHP,HBHCMFHR,HBHCMFHS,HBHCNAME,HBHCNOD0,HBHCPAGE,HBHCTDY,HBHCTMP,HBHCTOT,HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$J)
Q
PROCESS ; Process record & build ^TMP("HBHC",$J) global
Q:($P(HBHCNOD0,U,40)]"")&($P(HBHCNOD0,U,40)<HBHCEND1)
; Quit if Medical Foster Home (MFH) Report, but not MFH patient; HBHCMFHR variable set in MFH^HBHCUTL3
I $D(HBHCMFHR) Q:'$D(^HBHC(631,"AJ","Y",HBHCDFN))
S HBHCDPT0=^DPT($P(HBHCNOD0,U),0)
I '$D(HBHCMFHS) S ^TMP("HBHC",$J,$P(HBHCDPT0,U),HBHCADDT)=$E($P(HBHCDPT0,U,9),6,9)
I $D(HBHCMFHS) S HBHCMFHN="",HBHCMFHP=$P($G(^HBHC(631,HBHCDFN,3)),U,2) S:HBHCMFHP]"" HBHCMFHN=$E($P(^HBHC(633.2,HBHCMFHP,0),U),1,25) S ^TMP("HBHC",$J,$P(HBHCDPT0,U),HBHCADDT)=$E($P(HBHCDPT0,U,9),6,9)_U_HBHCMFHN
Q
PRTLOOP ; Print loop
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
Q
PRINT ; Print report
I ($D(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<5) W @IOF D HDRRANGE^HBHCUTL
S Y=HBHCADDT D DD^%DT
W:'$D(HBHCMFHS) !,HBHCNAME,?43,^TMP("HBHC",$J,HBHCNAME,HBHCADDT),?68,Y,!,HBHCY
I $D(HBHCMFHS) S HBHCTMP=^TMP("HBHC",$J,HBHCNAME,HBHCADDT) W !,HBHCNAME,?33,$P(HBHCTMP,U),?40,Y,?55,$P(HBHCTMP,U,2),!,HBHCY
S HBHCTOT=HBHCTOT+1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHBHCRP10 3128 printed Nov 22, 2024@17:08:24 Page 2
HBHCRP10 ; LR VAMC(IRMS)/MJT-HBHC report on file 631, All active (admitted but not discharged) cases by date range, sorted by patient name, includes: patient name, Last Four, admission date, & total ; 12/21/05 3:31pm
+1 ;;1.0;HOSPITAL BASED HOME CARE;**6,22,24**;NOV 01, 1993;Build 201
+2 DO START^HBHCUTL
+3 if (HBHCBEG1=-1)!(HBHCEND1=-1)
GOTO EXIT
+4 WRITE !
DO MFHS^HBHCUTL3
if $DATA(HBHCMFHS)
DO MFH^HBHCUTL3
+5 if $DATA(DIRUT)
GOTO EXIT
+6 SET %ZIS="Q"
SET HBHCCC=0
KILL IOP,ZTIO,ZTSAVE
DO ^%ZIS
if POP
GOTO EXIT
+7 IF $DATA(IO("Q"))
SET ZTRTN="DQ^HBHCRP10"
SET ZTDESC="HBPC Program Census Report"
SET ZTSAVE("HBHC*")=""
DO ^%ZTLOAD
GOTO EXIT
DQ ; De-queue
+1 USE IO
+2 SET HBHCTOT=0
SET $PIECE(HBHCY,"-",81)=""
SET HBHCHEAD="Program Census"
+3 ; HBHCMFHS variable set in MFHS^HBHCUTL3
+4 if '$DATA(HBHCMFHS)
SET HBHCHDR="W !,""Patient Name"",?43,""Last Four"",?68,""Date"""
+5 if $DATA(HBHCMFHS)
SET HBHCHDR="W !,?33,""Last"",!,""Patient Name"",?33,""Four"",?40,""Date"",?55,""Medical Foster Name Name"""
+6 ; HBHCMFHR variable set in MFH^HBHCUTL3
+7 if $DATA(HBHCMFHR)
SET HBHCHEAD="Medical Foster Home (MFH) "_HBHCHEAD
+8 SET HBHCCOLM=(80-(30+$LENGTH(HBHCHEAD))\2)
if HBHCCOLM'>0
SET HBHCCOLM=1
+9 DO TODAY^HBHCUTL
if IO'=IO(0)!($DATA(IO("S")))
DO HDRRANGE^HBHCUTL
+10 IF '$DATA(IO("S"))
IF (IO=IO(0))
SET HBHCCC=HBHCCC+1
DO HDRRANGE^HBHCUTL
LOOP ; Loop thru ^HBHC(631) "AD" (admission date) cross-ref to build report
+1 SET X1=HBHCBEG1
SET X2=-1
DO C^%DTC
SET HBHCADDT=X
+2 FOR
SET HBHCADDT=$ORDER(^HBHC(631,"AD",HBHCADDT))
if (HBHCADDT="")!(HBHCADDT>HBHCEND1)
QUIT
SET HBHCDFN=""
FOR
SET HBHCDFN=$ORDER(^HBHC(631,"AD",HBHCADDT,HBHCDFN))
if HBHCDFN=""
QUIT
SET HBHCNOD0=^HBHC(631,HBHCDFN,0)
if $PIECE(HBHCNOD0,U,15)=1
DO PROCESS
+3 if '$DATA(^TMP("HBHC",$JOB))
WRITE !!,"No data found for Date Range selected."
+4 IF $DATA(^TMP("HBHC",$JOB))
DO PRTLOOP
WRITE !!,HBHCZ,!,"Program Census Total: ",HBHCTOT,!,HBHCZ
+5 DO ENDRPT^HBHCUTL1
EXIT ; Exit module
+1 DO ^%ZISC
+2 KILL DIR,HBHCADDT,HBHCBEG1,HBHCBEG2,HBHCCOLM,HBHCCC,HBHCDFN,HBHCDPT0,HBHCEND1,HBHCEND2,HBHCHDR,HBHCHEAD,HBHCMFHN,HBHCMFHP,HBHCMFHR,HBHCMFHS,HBHCNAME,HBHCNOD0,HBHCPAGE,HBHCTDY,HBHCTMP,HBHCTOT,HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$JOB)
+3 QUIT
PROCESS ; Process record & build ^TMP("HBHC",$J) global
+1 if ($PIECE(HBHCNOD0,U,40)]"")&($PIECE(HBHCNOD0,U,40)<HBHCEND1)
QUIT
+2 ; Quit if Medical Foster Home (MFH) Report, but not MFH patient; HBHCMFHR variable set in MFH^HBHCUTL3
+3 IF $DATA(HBHCMFHR)
if '$DATA(^HBHC(631,"AJ","Y",HBHCDFN))
QUIT
+4 SET HBHCDPT0=^DPT($PIECE(HBHCNOD0,U),0)
+5 IF '$DATA(HBHCMFHS)
SET ^TMP("HBHC",$JOB,$PIECE(HBHCDPT0,U),HBHCADDT)=$EXTRACT($PIECE(HBHCDPT0,U,9),6,9)
+6 IF $DATA(HBHCMFHS)
SET HBHCMFHN=""
SET HBHCMFHP=$PIECE($GET(^HBHC(631,HBHCDFN,3)),U,2)
if HBHCMFHP]""
SET HBHCMFHN=$EXTRACT($PIECE(^HBHC(633.2,HBHCMFHP,0),U),1,25)
SET ^TMP("HBHC",$JOB,$PIECE(HBHCDPT0,U),HBHCADDT)=$EXTRACT($PIECE(HBHCDPT0,U,9),6,9)_U_HBHCMFHN
+7 QUIT
PRTLOOP ; Print loop
+1 SET HBHCNAME=""
FOR
SET HBHCNAME=$ORDER(^TMP("HBHC",$JOB,HBHCNAME))
if HBHCNAME=""
QUIT
SET HBHCADDT=""
FOR
SET HBHCADDT=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCADDT))
if HBHCADDT=""
QUIT
DO PRINT
+2 QUIT
PRINT ; Print report
+1 IF ($DATA(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<5)
WRITE @IOF
DO HDRRANGE^HBHCUTL
+2 SET Y=HBHCADDT
DO DD^%DT
+3 if '$DATA(HBHCMFHS)
WRITE !,HBHCNAME,?43,^TMP("HBHC",$JOB,HBHCNAME,HBHCADDT),?68,Y,!,HBHCY
+4 IF $DATA(HBHCMFHS)
SET HBHCTMP=^TMP("HBHC",$JOB,HBHCNAME,HBHCADDT)
WRITE !,HBHCNAME,?33,$PIECE(HBHCTMP,U),?40,Y,?55,$PIECE(HBHCTMP,U,2),!,HBHCY
+5 SET HBHCTOT=HBHCTOT+1
+6 QUIT