source: WorldVistAEHR/trunk/r/HOSPITAL_BASED_HOME_CARE-HBH/HBHCRP21.m@ 1578

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

initial load of WorldVistAEHR

File size: 7.2 KB
RevLine 
[613]1HBHCRP21 ; 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
2 ;;1.0;HOSPITAL BASED HOME CARE;**11,13,15,16,19**;NOV 01, 1993
3 D START^HBHCUTL
4 G:(HBHCBEG1=-1)!(HBHCEND1=-1) EXIT
5 W !,"Visits containing any of the following CPT Codes are omitted from report:"
6 W !!?2,"99358 PROLONGED SERV, W/O CONTACT"
7 W !?2,"99359 PROLONGED SERV, W/O CONTACT"
8 W !?2,"99361 PHYSICIAN/TEAM CONFERENCE"
9 W !?2,"99362 PHYSICIAN/TEAM CONFERENCE"
10 W !?2,"99371 PHYSICIAN PHONE CONSULTATION"
11 W !?2,"99372 PHYSICIAN PHONE CONSULTATION"
12 W !?2,"99373 PHYSICIAN PHONE CONSULTATION"
13 W !?2,"99374 HOME HEALTH CARE SUPERVISION"
14 W !?2,"99375 HOME HEALTH CARE SUPERVISION"
15 W !?2,"99376 CARE PLAN OVERSIGHT/OVER 60",!
16PROMPT ; Prompt user for CPT code
17 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
18 G:$D(DTOUT) EXIT I '$D(DUOUT) I X'="" S HBHCCPTL(X)="" G PROMPT
19 W !
20 ; Prompt user for sort preference
21 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
22 G:$D(DIRUT) EXIT
23 ; HBHCFLG exists if visit sort selected
24 S:X="V" HBHCFLG=1
25 S %ZIS="Q",HBHCCC=0 K IOP,ZTIO,ZTSAVE D ^%ZIS G:POP EXIT
26 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
27DQ ; De-queue
28 ; CPT codes omitted from inclusion on report
29 S HBHCCPTL(99358)="",HBHCCPTL(99359)="",HBHCCPTL(99361)="",HBHCCPTL(99362)="",HBHCCPTL(99371)="",HBHCCPTL(99372)="",HBHCCPTL(99373)="",HBHCCPTL(99374)="",HBHCCPTL(99375)="",HBHCCPTL(99376)=""
30 U IO
31 K ^TMP("HBHC",$J)
32 S $P(HBHCY,"-",81)="",$P(HBHCZ,"=",81)="",(HBHCCNT,HBHCCNT1,HBHCTOT)=0
33 S HBHCHEAD=$S($D(HBHCFLG):"Total Visits by Date Range, Visit Sort",1:"Total Visits by Date Range")
34 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
35LOOP ; Loop thru ^HBHC(632) "C" (appointment date) cross-ref to build report
36 S X1=HBHCBEG1,X2=-1 D C^%DTC S HBHCAPDT=X_.9999
37 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
38 D TODAY^HBHCUTL D:IO'=IO(0)!($D(IO("S"))) HDRRANGE^HBHCUTL
39 I '$D(IO("S")),(IO=IO(0)) S HBHCCC=HBHCCC+1 D HDRRANGE^HBHCUTL
40 W:'$D(^TMP("HBHC",$J)) !!,"No Visits found for Date Range selected."
41 I $D(^TMP("HBHC",$J)) W !!,"Visits containing any of the following CPT Codes are omitted from report:",! S HBHCCPT="" F S HBHCCPT=$O(HBHCCPTL(HBHCCPT)) Q:HBHCCPT="" S HBHC=$$CPT^ICPTCOD(HBHCCPT) W !?2,$P(HBHC,U,2)_" "_$P(HBHC,U,3)
42 I $D(^TMP("HBHC",$J)) W !!,HBHCY D:$D(HBHCFLG) SORT,PRTLOOP,SUMMARY I '$D(HBHCFLG) D APRTLOOP W !!,"Total Patients: ",$J(HBHCCNT,4),!!,"Total Visits: ",$J(HBHCTOT,6)
43 D ENDRPT^HBHCUTL1
44EXIT ; Exit module
45 D ^%ZISC
46 K DIR,HBHC,HBHCADDT,HBHCAPDT,HBHCBEG1,HBHCBEG2,HBHCCC,HBHCCNT,HBHCCNT1,HBHCCOLM,HBHCCPT,HBHCCPTL,HBHCDFN,HBHCDPT0,HBHCDSDT,HBHCEND1,HBHCEND2,HBHCFLAG,HBHCFLG,HBHCHEAD,HBHCHDR,HBHCI,HBHCIEN,HBHCINFO,HBHCNAME,HBHCNBR,HBHCNOD0
47 K HBHCPAGE,HBHCLST4,HBHCTDY,HBHCTOT,HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$J)
48 Q
49PROCESS ; Process record & build ^TMP("HBHC",$J) global
50 ; Quit if no CPT codes
51 D CPT^HBHCUTL3 Q:'$D(HBHCCPTA)
52 ; Quit if contains CPT code to be omitted
53 K HBHCFLAG
54 S HBHCI="" F S HBHCI=$O(HBHCCPTA(HBHCI)) Q:(HBHCI="")!($D(HBHCFLAG)) S HBHCCPT=$P(HBHCCPTA(HBHCI)," ") S:$D(HBHCCPTL(HBHCCPT)) HBHCFLAG=1
55 Q:$D(HBHCFLAG)
56 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)
57 S (HBHCADDT,HBHCDSDT)=""
58 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)
59 ; patient not in HBHC(631
60 S:HBHCADDT="" HBHCADDT="n/a"
61 S:HBHCDSDT="" HBHCDSDT="n/a"
62 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
63 S:'$D(^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)) ^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=1
64 Q
65SORT ; Sort TMP according to number of visits
66 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
67 Q
68SORTLOOP ; Sort loop
69 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
70 Q
71SET ; Set TMP in re-sorted order by number of visits, kill old TMP node
72 S HBHCNBR=^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
73 S ^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)=HBHCNBR
74 K ^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
75 Q
76PRTLOOP ; Print loop
77 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
78 Q
79PRTLOOP2 ; Print loop continued
80 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
81 Q
82PRTLOOP3 ; Print loop continued again
83 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
84 Q
85APRTLOOP ; Print loop for alphabetic sort
86 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
87 Q
88APRTLP2 ; Print loop for alphabetic sort continued
89 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
90 Q
91PRINT ; Print report
92 S HBHCCNT=HBHCCNT+1
93 S:$D(HBHCFLG) HBHCINFO=^TMP("HBHC",$J,HBHCNBR,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT),HBHCCNT1=HBHCCNT1+1
94 S:'$D(HBHCFLG) HBHCINFO=^TMP("HBHC",$J,HBHCNAME,HBHCLST4,HBHCADDT,HBHCDSDT)
95 I ($D(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<7) W @IOF D HDRRANGE^HBHCUTL
96 S HBHCTOT=HBHCTOT+($P(HBHCINFO,U))
97 W !,$E(HBHCNAME,1,25),?31,$E(HBHCLST4,8,11),?41,$J($P(HBHCINFO,U),3)
98 S Y=HBHCADDT D DD^%DT W ?50,Y
99 S Y=HBHCDSDT D DD^%DT W ?68,$S(Y'="n/a":Y,1:"")
100 W !,HBHCY
101 Q
102SUMMARY ; Print report summary
103 W @IOF,HBHCZ,!?22,"****** Total Visits Summary ******",!,HBHCZ,!
104 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)
105 W !?34,"------",!,"Total Patients: ",?35,$J(HBHCCNT,4),!!,"Total Visits: ",?33,$J(HBHCTOT,6)
106 Q
Note: See TracBrowser for help on using the repository browser.