Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HBHCRP21

HBHCRP21.m

Go to the documentation of this file.
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