HBHCRP21 ; LR VAMC(IRMS)/MJT-HBHC report on file 632, number of pat visits by date range, with total pats & total visits, user selectable alpha or number of visits sort, number of visits has subtotals & summary, calls CPT^HBHCUTL3 ; Apr 2000
;;1.0;HOSPITAL BASED HOME CARE;**11,13,15,16,19,28**;NOV 01, 1993;Build 208
D START^HBHCUTL
G:(HBHCBEG1=-1)!(HBHCEND1=-1) EXIT
D OMIT
PROMPT ; Prompt user for CPT code
K DIR S DIR(0)="PO^81",DIR("A")="Enter any other CPT code you wish to omit",DIR("?")="Enter 5 digit CPT code you wish to omit from report." D ^DIR
G:$D(DTOUT) EXIT I '$D(DUOUT) I X'="" S HBHCCPTL(X)="" G PROMPT
W !
; Prompt user for sort preference
K DIR S DIR(0)="SM^A:Alphabetical;V:Number of Visits",DIR("A")="Sort Preference",DIR("B")="V",DIR("?")="Sort report alphabetically by patient (A), or by number of visits (V). Visit sort includes subtotals & summary." D ^DIR
G:$D(DIRUT) EXIT
; HBHCFLG exists if visit sort selected
S:X="V" HBHCFLG=1
S %ZIS="Q",HBHCCC=0 K IOP,ZTIO,ZTSAVE D ^%ZIS G:POP EXIT
I $D(IO("Q")) S ZTRTN="DQ^HBHCRP21",ZTDESC=$S($D(HBHCFLG):"HBPC Total Visits by Date Range Report,Visit Sort",1:"HBPC Total Visits by Date Range Report"),ZTSAVE("HBHC*")="" D ^%ZTLOAD G EXIT
DQ ; De-queue
; CPT codes omitted from inclusion on report
; Active
S HBHCCPTL(98966)="",HBHCCPTL(98967)="",HBHCCPTL(98968)="",HBHCCPTL(99358)="",HBHCCPTL(99359)="",HBHCCPTL(99367)="",HBHCCPTL(99368)="",HBHCCPTL(99374)="",HBHCCPTL(99375)="",HBHCCPTL(99441)="",HBHCCPTL(99442)="",HBHCCPTL(99443)=""
; Inactive/Historical
S HBHCCPTL(99361)="",HBHCCPTL(99362)="",HBHCCPTL(99371)="",HBHCCPTL(99372)="",HBHCCPTL(99373)="",HBHCCPTL(99376)=""
U IO
K ^TMP("HBHC",$J)
S $P(HBHCY,"-",81)="",$P(HBHCZ,"=",81)="",(HBHCCNT,HBHCCNT1,HBHCTOT)=0
S HBHCHEAD=$S($D(HBHCFLG):"Total Visits by Date Range, Visit Sort",1:"Total Visits by Date Range")
S HBHCHDR="W !?31,""Last"",?40,""Visit"",?68,""Discharge"",!,""Patient Name"",?31,""Four"",?40,""Total"",?50,""Date"",?68,""Date""",HBHCCOLM=(80-(30+$L(HBHCHEAD))\2) S:HBHCCOLM'>0 HBHCCOLM=1
LOOP ; Loop thru ^HBHC(632) "C" (appointment date) cross-ref to build report
S X1=HBHCBEG1,X2=-1 D C^%DTC S HBHCAPDT=X_.9999
F S HBHCAPDT=$O(^HBHC(632,"C",HBHCAPDT)) Q:(HBHCAPDT="")!(HBHCAPDT>HBHCEND1) S HBHCDFN="" F S HBHCDFN=$O(^HBHC(632,"C",HBHCAPDT,HBHCDFN)) Q:HBHCDFN="" S HBHCNOD0=^HBHC(632,HBHCDFN,0) D:$P(HBHCNOD0,U,7)="" PROCESS
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
W:'$D(^TMP("HBHC",$J)) !!,"No Visits found for Date Range selected."
I $D(^TMP("HBHC",$J)) D OMIT W !,HBHCY D:$D(HBHCFLG) SORT,PRTLOOP,SUMMARY I '$D(HBHCFLG) D APRTLOOP W !!,"Total Patients: ",$J(HBHCCNT,4),!!,"Total Visits: ",$J(HBHCTOT,6)
D ENDRPT^HBHCUTL1
EXIT ; Exit module
D ^%ZISC
K DIR,HBHC,HBHCADDT,HBHCAPDT,HBHCBEG1,HBHCBEG2,HBHCCC,HBHCCNT,HBHCCNT1,HBHCCOLM,HBHCCPT,HBHCCPTA,HBHCCPTL,HBHCDFN,HBHCDPT0,HBHCDSDT,HBHCEND1,HBHCEND2,HBHCFLAG,HBHCFLG,HBHCHEAD,HBHCHDR,HBHCI,HBHCIEN,HBHCINFO,HBHCNAME,HBHCNBR,HBHCNOD0
K HBHCPAGE,HBHCLST4,HBHCTDY,HBHCTOT,HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$J)
Q
PROCESS ; Process record & build ^TMP("HBHC",$J) global
; Quit if no CPT codes
D CPT^HBHCUTL3 Q:'$D(HBHCCPTA)
; Quit if contains CPT code to be omitted
K HBHCFLAG
S HBHCI="" F S HBHCI=$O(HBHCCPTA(HBHCI)) Q:(HBHCI="")!($D(HBHCFLAG)) S HBHCCPT=$P(HBHCCPTA(HBHCI)," ") S:$D(HBHCCPTL(HBHCCPT)) HBHCFLAG=1
Q:$D(HBHCFLAG)
S HBHCDPT0=^DPT($P(HBHCNOD0,U),0),HBHCNAME=$P(HBHCDPT0,U),HBHCLST4=$E($P(HBHCDPT0,U,9),1,3)_"-"_$E($P(HBHCDPT0,U,9),4,5)_"-"_$E($P(HBHCDPT0,U,9),6,9)
S (HBHCADDT,HBHCDSDT)=""
S HBHCIEN=0 F S HBHCIEN=$O(^HBHC(631,"B",$P(HBHCNOD0,U),HBHCIEN)) Q:HBHCIEN'>0 S HBHCINFO=^HBHC(631,HBHCIEN,0),HBHCADDT=$P(HBHCINFO,U,18),HBHCDSDT=$P(HBHCINFO,U,40)
; patient not in HBHC(631
S:HBHCADDT="" HBHCADDT="n/a"
S:HBHCDSDT="" HBHCDSDT="n/a"
I $D(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)) S ^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)+1
S:'$D(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)) ^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=1
Q
SORT ; Sort TMP according to number of visits
S HBHCNAME="" F S HBHCNAME=$O(^TMP("HBHC",$J,HBHCNAME)) Q:HBHCNAME="" S HBHCLST4="" F S HBHCLST4=$O(^TMP("HBHC",$J,HBHCNAME,HBHCLST4)) Q:HBHCLST4="" D SORTLOOP
Q
SORTLOOP ; Sort loop
S HBHCADDT="" F S HBHCADDT=$O(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT)) Q:HBHCADDT="" S HBHCDSDT="" F S HBHCDSDT=$O(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)) Q:HBHCDSDT="" D SET
Q
SET ; Set TMP in re-sorted order by number of visits, kill old TMP node
S HBHCNBR=^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
S ^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=HBHCNBR
K ^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
Q
PRTLOOP ; Print loop
S HBHCNBR="" F S HBHCNBR=$O(^TMP("HBHC",$J,HBHCNBR)) Q:HBHCNBR="" D PRTLOOP2 W:HBHCCNT1>0 !!?5,"Total Patients with ",HBHCNBR," Visit(s): ",HBHCCNT1,!!,HBHCY S HBHC(HBHCNBR)=HBHCCNT1,HBHCCNT1=0
Q
PRTLOOP2 ; Print loop continued
S HBHCNAME="" F S HBHCNAME=$O(^TMP("HBHC",$J,HBHCNBR,HBHCNAME)) Q:HBHCNAME="" S HBHCLST4="" F S HBHCLST4=$O(^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4)) Q:HBHCLST4="" D PRTLOOP3
Q
PRTLOOP3 ; Print loop continued again
S HBHCADDT="" F S HBHCADDT=$O(^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT)) Q:HBHCADDT="" S HBHCDSDT="" F S HBHCDSDT=$O(^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)) Q:HBHCDSDT="" D PRINT
Q
APRTLOOP ; Print loop for alphabetic sort
S HBHCNAME="" F S HBHCNAME=$O(^TMP("HBHC",$J,HBHCNAME)) Q:HBHCNAME="" S HBHCLST4="" F S HBHCLST4=$O(^TMP("HBHC",$J,HBHCNAME,HBHCLST4)) Q:HBHCLST4="" D APRTLP2
Q
APRTLP2 ; Print loop for alphabetic sort continued
S HBHCADDT="" F S HBHCADDT=$O(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT)) Q:HBHCADDT="" S HBHCDSDT="" F S HBHCDSDT=$O(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)) Q:HBHCDSDT="" D PRINT
Q
PRINT ; Print report
S HBHCCNT=HBHCCNT+1
S:$D(HBHCFLG) HBHCINFO=^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT),HBHCCNT1=HBHCCNT1+1
S:'$D(HBHCFLG) HBHCINFO=^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
I ($D(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<7) W @IOF D HDRRANGE^HBHCUTL
S HBHCTOT=HBHCTOT+($P(HBHCINFO,U))
W !,$E(HBHCNAME,1,25),?31,$E(HBHCLST4,8,11),?41,$J($P(HBHCINFO,U),3)
S Y=HBHCADDT D DD^%DT W ?50,Y
S Y=HBHCDSDT D DD^%DT W ?68,$S(Y'="n/a":Y,1:"")
W !,HBHCY
Q
SUMMARY ; Print report summary
W @IOF,HBHCZ,!?22,"****** Total Visits Summary ******",!,HBHCZ,!
S HBHCNBR=0 F S HBHCNBR=$O(HBHC(HBHCNBR)) Q:HBHCNBR'>0 W !,"Total Patients with ",$J(HBHCNBR,3)," Visit(s): ",$J(HBHC(HBHCNBR),4)
W !?34,"------",!,"Total Patients: ",?35,$J(HBHCCNT,4),!!,"Total Visits: ",?33,$J(HBHCTOT,6)
Q
OMIT ; Print Omitted CPT Codes listing
W !,"Visits containing any of the following CPT Codes are omitted from report:"
W !!?4,"Active",?46,"Inactive/Historical"
W !?2,"98966 HC PRO PHONE CALL 5-10 MIN",?44,"99361 PHYSICIAN/TEAM CONFERENCE"
W !?2,"98967 HC PRO PHONE CALL 11-20 MIN",?44,"99362 PHYSICIAN/TEAM CONFERENCE"
W !?2,"98968 HC PRO PHONE CALL 21-30 MIN",?44,"99371 PHYSICIAN PHONE CONSULTATION"
W !?2,"99358 PROLONGED SERV, W/O CONTACT",?44,"99372 PHYSICIAN PHONE CONSULTATION"
W !?2,"99359 PROLONGED SERV, W/O CONTACT",?44,"99373 PHYSICIAN PHONE CONSULTATION"
W !?2,"99367 TEAM CONF W/O PAT BY PHYS",?44,"99376 CARE PLAN OVERSIGHT/OVER 60"
W !?2,"99368 TEAM CONF W/O PAT BY HC PRO"
W !?2,"99374 HOME HEALTH CARE SUPERVISION"
W !?2,"99375 HOME HEALTH CARE SUPERVISION"
W !?2,"99441 PHONE E/M PHYS/QHP 5-10 MIN"
W !?2,"99442 PHONE E/M PHYS/QHP 11-20 MIN"
W !?2,"99443 PHONE E/M PHYS/QHP 21-30 MIN",!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHBHCRP21 7895 printed Dec 13, 2024@01:58:26 Page 2
HBHCRP21 ; LR VAMC(IRMS)/MJT-HBHC report on file 632, number of pat visits by date range, with total pats & total visits, user selectable alpha or number of visits sort, number of visits has subtotals & summary, calls CPT^HBHCUTL3 ; Apr 2000
+1 ;;1.0;HOSPITAL BASED HOME CARE;**11,13,15,16,19,28**;NOV 01, 1993;Build 208
+2 DO START^HBHCUTL
+3 if (HBHCBEG1=-1)!(HBHCEND1=-1)
GOTO EXIT
+4 DO OMIT
PROMPT ; Prompt user for CPT code
+1 KILL DIR
SET DIR(0)="PO^81"
SET DIR("A")="Enter any other CPT code you wish to omit"
SET DIR("?")="Enter 5 digit CPT code you wish to omit from report."
DO ^DIR
+2 if $DATA(DTOUT)
GOTO EXIT
IF '$DATA(DUOUT)
IF X'=""
SET HBHCCPTL(X)=""
GOTO PROMPT
+3 WRITE !
+4 ; Prompt user for sort preference
+5 KILL DIR
SET DIR(0)="SM^A:Alphabetical;V:Number of Visits"
SET DIR("A")="Sort Preference"
SET DIR("B")="V"
SET DIR("?")="Sort report alphabetically by patient (A), or by number of visits (V). Visit sort includes subtotals & summary."
DO ^DIR
+6 if $DATA(DIRUT)
GOTO EXIT
+7 ; HBHCFLG exists if visit sort selected
+8 if X="V"
SET HBHCFLG=1
+9 SET %ZIS="Q"
SET HBHCCC=0
KILL IOP,ZTIO,ZTSAVE
DO ^%ZIS
if POP
GOTO EXIT
+10 IF $DATA(IO("Q"))
SET ZTRTN="DQ^HBHCRP21"
SET ZTDESC=$SELECT($DATA(HBHCFLG):"HBPC Total Visits by Date Range Report,Visit Sort",1:"HBPC Total Visits by Date Range Report")
SET ZTSAVE("HBHC*")=""
DO ^%ZTLOAD
GOTO EXIT
DQ ; De-queue
+1 ; CPT codes omitted from inclusion on report
+2 ; Active
+3 SET HBHCCPTL(98966)=""
SET HBHCCPTL(98967)=""
SET HBHCCPTL(98968)=""
SET HBHCCPTL(99358)=""
SET HBHCCPTL(99359)=""
SET HBHCCPTL(99367)=""
SET HBHCCPTL(99368)=""
SET HBHCCPTL(99374)=""
SET HBHCCPTL(99375)=""
SET HBHCCPTL(99441)=""
SET HBHCCPTL(99442)=""
SET HBHCCPTL(99443)=""
+4 ; Inactive/Historical
+5 SET HBHCCPTL(99361)=""
SET HBHCCPTL(99362)=""
SET HBHCCPTL(99371)=""
SET HBHCCPTL(99372)=""
SET HBHCCPTL(99373)=""
SET HBHCCPTL(99376)=""
+6 USE IO
+7 KILL ^TMP("HBHC",$JOB)
+8 SET $PIECE(HBHCY,"-",81)=""
SET $PIECE(HBHCZ,"=",81)=""
SET (HBHCCNT,HBHCCNT1,HBHCTOT)=0
+9 SET HBHCHEAD=$SELECT($DATA(HBHCFLG):"Total Visits by Date Range, Visit Sort",1:"Total Visits by Date Range")
+10 SET HBHCHDR="W !?31,""Last"",?40,""Visit"",?68,""Discharge"",!,""Patient Name"",?31,""Four"",?40,""Total"",?50,""Date"",?68,""Date"""
SET HBHCCOLM=(80-(30+$LENGTH(HBHCHEAD))\2)
if HBHCCOLM'>0
SET HBHCCOLM=1
LOOP ; Loop thru ^HBHC(632) "C" (appointment date) cross-ref to build report
+1 SET X1=HBHCBEG1
SET X2=-1
DO C^%DTC
SET HBHCAPDT=X_.9999
+2 FOR
SET HBHCAPDT=$ORDER(^HBHC(632,"C",HBHCAPDT))
if (HBHCAPDT="")!(HBHCAPDT>HBHCEND1)
QUIT
SET HBHCDFN=""
FOR
SET HBHCDFN=$ORDER(^HBHC(632,"C",HBHCAPDT,HBHCDFN))
if HBHCDFN=""
QUIT
SET HBHCNOD0=^HBHC(632,HBHCDFN,0)
if $PIECE(HBHCNOD0,U,7)=""
DO PROCESS
+3 DO TODAY^HBHCUTL
if IO'=IO(0)!($DATA(IO("S")))
DO HDRRANGE^HBHCUTL
+4 IF '$DATA(IO("S"))
IF (IO=IO(0))
SET HBHCCC=HBHCCC+1
DO HDRRANGE^HBHCUTL
+5 if '$DATA(^TMP("HBHC",$JOB))
WRITE !!,"No Visits found for Date Range selected."
+6 IF $DATA(^TMP("HBHC",$JOB))
DO OMIT
WRITE !,HBHCY
if $DATA(HBHCFLG)
DO SORT
DO PRTLOOP
DO SUMMARY
IF '$DATA(HBHCFLG)
DO APRTLOOP
WRITE !!,"Total Patients: ",$JUSTIFY(HBHCCNT,4),!!,"Total Visits: ",$JUSTIFY(HBHCTOT,6)
+7 DO ENDRPT^HBHCUTL1
EXIT ; Exit module
+1 DO ^%ZISC
+2 KILL DIR,HBHC,HBHCADDT,HBHCAPDT,HBHCBEG1,HBHCBEG2,HBHCCC,HBHCCNT,HBHCCNT1,HBHCCOLM,HBHCCPT,HBHCCPTA,HBHCCPTL,HBHCDFN,HBHCDPT0,HBHCDSDT,HBHCEND1,HBHCEND2,HBHCFLAG,HBHCFLG,HBHCHEAD,HBHCHDR,HBHCI,HBHCIEN,HBHCINFO,HBHCNAME,HBHCNBR,HBHCNOD0
+3 KILL HBHCPAGE,HBHCLST4,HBHCTDY,HBHCTOT,HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$JOB)
+4 QUIT
PROCESS ; Process record & build ^TMP("HBHC",$J) global
+1 ; Quit if no CPT codes
+2 DO CPT^HBHCUTL3
if '$DATA(HBHCCPTA)
QUIT
+3 ; Quit if contains CPT code to be omitted
+4 KILL HBHCFLAG
+5 SET HBHCI=""
FOR
SET HBHCI=$ORDER(HBHCCPTA(HBHCI))
if (HBHCI="")!($DATA(HBHCFLAG))
QUIT
SET HBHCCPT=$PIECE(HBHCCPTA(HBHCI)," ")
if $DATA(HBHCCPTL(HBHCCPT))
SET HBHCFLAG=1
+6 if $DATA(HBHCFLAG)
QUIT
+7 SET HBHCDPT0=^DPT($PIECE(HBHCNOD0,U),0)
SET HBHCNAME=$PIECE(HBHCDPT0,U)
SET HBHCLST4=$EXTRACT($PIECE(HBHCDPT0,U,9),1,3)_"-"_$EXTRACT($PIECE(HBHCDPT0,U,9),4,5)_"-"_$EXTRACT($PIECE(HBHCDPT0,U,9),6,9)
+8 SET (HBHCADDT,HBHCDSDT)=""
+9 SET HBHCIEN=0
FOR
SET HBHCIEN=$ORDER(^HBHC(631,"B",$PIECE(HBHCNOD0,U),HBHCIEN))
if HBHCIEN'>0
QUIT
SET HBHCINFO=^HBHC(631,HBHCIEN,0)
SET HBHCADDT=$PIECE(HBHCINFO,U,18)
SET HBHCDSDT=$PIECE(HBHCINFO,U,40)
+10 ; patient not in HBHC(631
+11 if HBHCADDT=""
SET HBHCADDT="n/a"
+12 if HBHCDSDT=""
SET HBHCDSDT="n/a"
+13 IF $DATA(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT))
SET ^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)+1
+14 if '$DATA(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT))
SET ^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=1
+15 QUIT
SORT ; Sort TMP according to number of visits
+1 SET HBHCNAME=""
FOR
SET HBHCNAME=$ORDER(^TMP("HBHC",$JOB,HBHCNAME))
if HBHCNAME=""
QUIT
SET HBHCLST4=""
FOR
SET HBHCLST4=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4))
if HBHCLST4=""
QUIT
DO SORTLOOP
+2 QUIT
SORTLOOP ; Sort loop
+1 SET HBHCADDT=""
FOR
SET HBHCADDT=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT))
if HBHCADDT=""
QUIT
SET HBHCDSDT=""
FOR
SET HBHCDSDT=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT))
if HBHCDSDT=""
QUIT
DO SET
+2 QUIT
SET ; Set TMP in re-sorted order by number of visits, kill old TMP node
+1 SET HBHCNBR=^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
+2 SET ^TMP("HBHC",$JOB,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=HBHCNBR
+3 KILL ^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
+4 QUIT
PRTLOOP ; Print loop
+1 SET HBHCNBR=""
FOR
SET HBHCNBR=$ORDER(^TMP("HBHC",$JOB,HBHCNBR))
if HBHCNBR=""
QUIT
DO PRTLOOP2
if HBHCCNT1>0
WRITE !!?5,"Total Patients with ",HBHCNBR," Visit(s): ",HBHCCNT1,!!,HBHCY
SET HBHC(HBHCNBR)=HBHCCNT1
SET HBHCCNT1=0
+2 QUIT
PRTLOOP2 ; Print loop continued
+1 SET HBHCNAME=""
FOR
SET HBHCNAME=$ORDER(^TMP("HBHC",$JOB,HBHCNBR,HBHCNAME))
if HBHCNAME=""
QUIT
SET HBHCLST4=""
FOR
SET HBHCLST4=$ORDER(^TMP("HBHC",$JOB,HBHCNBR,HBHCNAME,HBHCLST4))
if HBHCLST4=""
QUIT
DO PRTLOOP3
+2 QUIT
PRTLOOP3 ; Print loop continued again
+1 SET HBHCADDT=""
FOR
SET HBHCADDT=$ORDER(^TMP("HBHC",$JOB,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT))
if HBHCADDT=""
QUIT
SET HBHCDSDT=""
FOR
SET HBHCDSDT=$ORDER(^TMP("HBHC",$JOB,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT))
if HBHCDSDT=""
QUIT
DO PRINT
+2 QUIT
APRTLOOP ; Print loop for alphabetic sort
+1 SET HBHCNAME=""
FOR
SET HBHCNAME=$ORDER(^TMP("HBHC",$JOB,HBHCNAME))
if HBHCNAME=""
QUIT
SET HBHCLST4=""
FOR
SET HBHCLST4=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4))
if HBHCLST4=""
QUIT
DO APRTLP2
+2 QUIT
APRTLP2 ; Print loop for alphabetic sort continued
+1 SET HBHCADDT=""
FOR
SET HBHCADDT=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT))
if HBHCADDT=""
QUIT
SET HBHCDSDT=""
FOR
SET HBHCDSDT=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT))
if HBHCDSDT=""
QUIT
DO PRINT
+2 QUIT
PRINT ; Print report
+1 SET HBHCCNT=HBHCCNT+1
+2 if $DATA(HBHCFLG)
SET HBHCINFO=^TMP("HBHC",$JOB,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
SET HBHCCNT1=HBHCCNT1+1
+3 if '$DATA(HBHCFLG)
SET HBHCINFO=^TMP("HBHC",$JOB,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
+4 IF ($DATA(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<7)
WRITE @IOF
DO HDRRANGE^HBHCUTL
+5 SET HBHCTOT=HBHCTOT+($PIECE(HBHCINFO,U))
+6 WRITE !,$EXTRACT(HBHCNAME,1,25),?31,$EXTRACT(HBHCLST4,8,11),?41,$JUSTIFY($PIECE(HBHCINFO,U),3)
+7 SET Y=HBHCADDT
DO DD^%DT
WRITE ?50,Y
+8 SET Y=HBHCDSDT
DO DD^%DT
WRITE ?68,$SELECT(Y'="n/a":Y,1:"")
+9 WRITE !,HBHCY
+10 QUIT
SUMMARY ; Print report summary
+1 WRITE @IOF,HBHCZ,!?22,"****** Total Visits Summary ******",!,HBHCZ,!
+2 SET HBHCNBR=0
FOR
SET HBHCNBR=$ORDER(HBHC(HBHCNBR))
if HBHCNBR'>0
QUIT
WRITE !,"Total Patients with ",$JUSTIFY(HBHCNBR,3)," Visit(s): ",$JUSTIFY(HBHC(HBHCNBR),4)
+3 WRITE !?34,"------",!,"Total Patients: ",?35,$JUSTIFY(HBHCCNT,4),!!,"Total Visits: ",?33,$JUSTIFY(HBHCTOT,6)
+4 QUIT
OMIT ; Print Omitted CPT Codes listing
+1 WRITE !,"Visits containing any of the following CPT Codes are omitted from report:"
+2 WRITE !!?4,"Active",?46,"Inactive/Historical"
+3 WRITE !?2,"98966 HC PRO PHONE CALL 5-10 MIN",?44,"99361 PHYSICIAN/TEAM CONFERENCE"
+4 WRITE !?2,"98967 HC PRO PHONE CALL 11-20 MIN",?44,"99362 PHYSICIAN/TEAM CONFERENCE"
+5 WRITE !?2,"98968 HC PRO PHONE CALL 21-30 MIN",?44,"99371 PHYSICIAN PHONE CONSULTATION"
+6 WRITE !?2,"99358 PROLONGED SERV, W/O CONTACT",?44,"99372 PHYSICIAN PHONE CONSULTATION"
+7 WRITE !?2,"99359 PROLONGED SERV, W/O CONTACT",?44,"99373 PHYSICIAN PHONE CONSULTATION"
+8 WRITE !?2,"99367 TEAM CONF W/O PAT BY PHYS",?44,"99376 CARE PLAN OVERSIGHT/OVER 60"
+9 WRITE !?2,"99368 TEAM CONF W/O PAT BY HC PRO"
+10 WRITE !?2,"99374 HOME HEALTH CARE SUPERVISION"
+11 WRITE !?2,"99375 HOME HEALTH CARE SUPERVISION"
+12 WRITE !?2,"99441 PHONE E/M PHYS/QHP 5-10 MIN"
+13 WRITE !?2,"99442 PHONE E/M PHYS/QHP 11-20 MIN"
+14 WRITE !?2,"99443 PHONE E/M PHYS/QHP 21-30 MIN",!
+15 QUIT