source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCRPW15.m@ 1604

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

initial load of WorldVistAEHR

File size: 9.1 KB
Line 
1SCRPW15 ;RENO/KEITH - Encounter Activity Report (Cont.) ;06/19/99
2 ;;5.3;Scheduling;**139,144,166,180,295**;AUG 13, 1993
3 ;06/19/99 ACS - Added CPT modifiers to the report
4 ;06/19/99 ACS - Added CPT modifier API calls
5 ;
6 N LINEFLAG
7 S SDIV="" F S SDIV=$O(^TMP("SCRPW",$J,SDIV)) Q:SDIV=""!SDOUT D DCAL
8 S SDLINE="",$P(SDLINE,"-",81)="" D NOW^%DTC S Y=% X ^DD("DD") S SDPNOW=$P(Y,":",1,2),(SDPAGE,SDFFS)=1
9 S SDIV="" F S SDIV=$O(SDDIV(SDIV)) Q:'SDIV S SDIV(SDDIV(SDIV))=SDIV
10 I 'SDDIV,$P(SDDIV,U,2)'="ALL DIVISIONS" S SDIV($P(SDDIV,U,2))=$$PRIM^VASITE()
11 I $P(SDDIV,U,2)="ALL DIVISIONS" S SDI=0 F S SDI=$O(^TMP("SCRPW",$J,SDI)) Q:'SDI S SDX=$P($G(^DG(40.8,SDI,0)),U) S:$L(SDX) SDIV(SDX)=SDI
12 D:$E(IOST)="C" DISP0^SCRPW23 I '$O(^TMP("SCRPW",$J,0)) S SDIV=0 D DHDR^SCRPW40(2,.SDT) D HDR() Q:SDOUT S SDX="No activity found within selected report parameters!" W !!?(80-$L(SDX)\2),SDX G EXIT
13 S SDIVN="" F S SDIVN=$O(SDIV(SDIVN)) Q:SDIVN=""!SDOUT S SDIV=SDIV(SDIVN) D DPRT(.SDIV)
14 S SDI=0,SDI=$O(^TMP("SCRPW",$J,SDI)),SDMD=$O(^TMP("SCRPW",$J,SDI))
15 G:SDOUT EXIT I SDMD S SDIV=0 D DPRT(.SDIV)
16 ;
17 I $E(IOST)="C",'$G(SDOUT) N DIR S DIR(0)="E" D ^DIR
18EXIT K SD,SDDIV G EXIT^SCRPW14
19 ;
20DCAL ;Calculate numbers for a division
21 D STOP^SCRPW14 Q:SDOUT
22 S SDS=0 F S SDS=$O(^TMP("SCRPW",$J,SDIV,1,SDS)) Q:'SDS D S1 S ^TMP("SCRPW",$J,SDIV,1,SDS,"VIS")=SDVS(SDIV),^TMP("SCRPW",$J,SDIV,1,SDS,"UNIQ")=SDUN(SDIV),^TMP("SCRPW",$J,SDIV,2,$$ORD(),SDS)=""
23 S (SDRPVS(SDIV),SDRPUN(SDIV),DFN)=0 F S DFN=$O(^TMP("SCRPW",$J,SDIV,"RPT","PT",DFN)) Q:'DFN S SDRPUN(SDIV)=SDRPUN(SDIV)+1,SDDT=0 F S SDDT=$O(^TMP("SCRPW",$J,SDIV,"RPT","PT",DFN,SDDT)) Q:'SDDT S SDRPVS(SDIV)=SDRPVS(SDIV)+1
24 Q
25 ;
26DPRT(SDIV) ;Print report for a division
27 S:SD("FMT")="D" SDDET=1 D T3 S SDPAGE=1 I '$D(^TMP("SCRPW",$J,SDIV)) S SDX="No activity found for this division!" D HDR() Q:SDOUT W !!?(80-$L(SDX)\2),SDX Q
28 D HDR() Q:SDOUT
29 S SDSV="" F S SDSV=$O(^TMP("SCRPW",$J,SDIV,2,SDSV),$S(SD("ORD")="A":1,1:-1)) Q:SDSV=""!SDOUT S SDS=0 F S SDS=$O(^TMP("SCRPW",$J,SDIV,2,SDSV,SDS)) Q:'SDS!SDOUT D PRT
30 Q:SDOUT I SD("FMT")="S" D RTOT Q
31 Q:SDOUT D:SD("FMT")="D" NONE Q
32 ;
33S1 S (SDVS(SDIV),SDUN(SDIV),SDPT)=0 F S SDPT=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PT",SDPT)) Q:'SDPT S SDUN(SDIV)=SDUN(SDIV)+1,SDDT=0 F S SDDT=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PT",SDPT,SDDT)) Q:'SDDT S SDVS(SDIV)=SDVS(SDIV)+1
34 Q:SD("FMT")="S"
35 S SDD=0 F S SDD=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD)) Q:'SDD S SDTOT=$G(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD,"PRI"))+$G(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD,"SEC")),^TMP("SCRPW",$J,SDIV,1,SDS,"DXTOT",SDTOT,SDD)=""
36 S SDP=0 F S SDP=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",SDP)) Q:'SDP S SDTOT=^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",SDP),^TMP("SCRPW",$J,SDIV,1,SDS,"PROCTOT",SDTOT,SDP)=""
37 Q
38 ;
39ORD() ;Produce sort value
40 Q:SD("ORD")="V" SDVS(SDIV) Q:SD("ORD")="U" SDUN(SDIV) Q:SD("ORD")="E" ^TMP("SCRPW",$J,SDIV,1,SDS,"ENC") Q $$SNAME()
41 ;
42HDR(SDPG) ;Print page header
43 D STOP^SCRPW14 Q:SDOUT
44 I $E(IOST)="C",'SDFFS N DIR S DIR(0)="E" D ^DIR S SDOUT=Y'=1 Q:SDOUT
45 S:$G(SDPG) SDPAGE=+SDPG W:'SDFFS $$XY^SCRPW50(IOF,1,0) W:$X $$XY^SCRPW50("",0,0) W SDLINE,!?22,"<*> ENCOUNTER ACTIVITY REPORT <*>"
46 N SDI S SDI=0 F S SDI=$O(SDTIT(SDI)) Q:'SDI W !?(80-$L(SDTIT(SDI))\2),SDTIT(SDI)
47 I SDPAGE=1 W !,SDLINE D PVIEW(15,1)
48 W !,SDLINE,!,"Date printed: ",SDPNOW,?(74-$L(SDPAGE)),"Page: ",SDPAGE,!,SDLINE,! S SDPAGE=SDPAGE+1,SDFFS=0
49 Q:'$D(^TMP("SCRPW",$J,SDIV))
50 Q:$G(SDPG)["N" I SD("FMT")="D",SDPAGE>2 W !,$S(SD("CAT")="C":"Clinic: ",SD("CAT")="P":"Provider: ",1:"Stop Code: "),$$SNAME()," (cont.)",! Q
51 W !,$S(SD("CAT")="C":"Clinic",SD("CAT")="P":"Provider",1:"Stop Code"),?40,"Encounters",?59,"Visits",?73,"Uniques",!,"------------------------------------",?40,"----------",?55,"----------",?70,"----------"
52 Q
53 ;
54RTOT ;Print report total
55 D:$Y>(IOSL-5) HDR() Q:SDOUT W !!,"====================================",?40,"==========",?55,"==========",?70,"==========",!!,"REPORT TOTAL:",?40,$J(SDRPEN(SDIV),10),?55,$J(SDRPVS(SDIV),10),?70,$J(SDRPUN(SDIV),10) Q
56 ;
57T3 K SDTIT D DHDR^SCRPW40(1,.SDTIT) Q
58 ;
59PVIEW(SDCOL,SDSKIP) ;Print report parameters
60 ;Required input: SDCOL=column to position output
61 ;Required input: SDSKIP=1 to skip division data on output
62 D:'$G(SDSKIP) PDIV W !?SDCOL," Activity date range: " S Y=SD("BDT") X ^DD("DD") W Y," to " S Y=$P(SD("EDT"),".") X ^DD("DD") W Y
63 W !?(SDCOL+8),"Report category: ",$S(SD("CAT")="C":"CLINIC",SD("CAT")="P":"PROVIDER",1:"STOP CODE")," perspective",!?(SDCOL+10),"Output format: ",$S(SD("FMT")="S":"SUMMARY",1:"DETAIL")
64 I SD("FMT")="S" W !?(SDCOL+8),"Collation order: ",$S(SD("ORD")="A":"ALPHABETIC",SD("ORD")="E":"by ENCOUNTER TOTAL",SD("ORD")="V":"by VISIT TOTAL",1:"by UNIQUE TOTAL")
65 W !?(SDCOL+7),"Encounter status: " S X=$O(SD("STAT",0)) W $P(^SD(409.63,X,0),U) F S X=$O(SD("STAT",X)) Q:'X W !?(SDCOL+25),$P(^SD(409.63,X,0),U)
66 Q
67 ;
68PDIV I 'SDDIV W !?SDCOL,"Medical Center Division: ",$P(SDDIV,U,2) Q
69 N SDI S SDI=0 F S SDI=$O(SDDIV(SDI)) Q:'SDI W !?SDCOL,"Medical Center Division: ",SDDIV(SDI)
70 Q
71 ;
72SNAME() ;Produce item name
73 Q:SD("CAT")="C" $P($G(^SC(SDS,0),"UNKNOWN"),U) Q:SD("CAT")="P" $P($G(^VA(200,SDS,0),"UNKNOWN"),U)
74 N X S X=$G(^DIC(40.7,SDS,0),"UNKNOWN^UNKNOWN"),X=$P(X,U,2)_" - "_$P(X,U) Q X
75 ;
76PRT ;Print data
77 I SD("FMT")="D",'$G(SDDET) D HDR(1) Q:SDOUT
78 D:$Y>(IOSL-4) HDR() Q:SDOUT K SDDET W !,$$SNAME(),?40,$J(^TMP("SCRPW",$J,SDIV,1,SDS,"ENC"),10),?55,$J(^TMP("SCRPW",$J,SDIV,1,SDS,"VIS"),10),?70,$J(^TMP("SCRPW",$J,SDIV,1,SDS,"UNIQ"),10) I SD("FMT")="D" D DX Q:SDOUT D PROC
79 Q
80 ;
81DX ;Print diagnosis information
82 D DXHD I '$D(^TMP("SCRPW",$J,SDIV,1,SDS,"DX")) W !!,"(No diagnosis information identified)" Q
83 S (SDT,SDTOT,SDTOT1,SDTOT2)="" F S SDT=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"DXTOT",SDT),-1) Q:SDT=""!SDOUT S SDD=0 F S SDD=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"DXTOT",SDT,SDD)) Q:'SDD!SDOUT D DX1
84 Q:SDOUT
85 W !,"====================================",?40,"==========",?55,"==========",?70,"==========",!,"TOTAL:",?40,$J(SDTOT1,10),?55,$J(SDTOT2,10),?70,$J(SDTOT,10) Q
86 ;
87DX1 ;
88 ;D:$Y>(IOSL-6) HDR(),DXHD Q:SDOUT S SDD0=^ICD9(SDD,0),SDT1=+$G(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD,"PRI")),SDT2=+$G(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD,"SEC")),SDTOT1=SDTOT1+SDT1,SDTOT2=SDTOT2+SDT2,SDTOT=SDTOT+SDT1+SDT2
89 ;W !,$P(SDD0,U),?7,$P(SDD0,U,3),?40,$J(SDT1,10),?55,$J(SDT2,10),?70,$J((SDT1+SDT2),10) Q
90 ;
91 D:$Y>(IOSL-6) HDR(),DXHD Q:SDOUT S SDD0=$$ICDDX^ICDCODE(SDD),SDT1=+$G(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD,"PRI")),SDT2=+$G(^TMP("SCRPW",$J,SDIV,1,SDS,"DX",SDD,"SEC")),SDTOT1=SDTOT1+SDT1,SDTOT2=SDTOT2+SDT2,SDTOT=SDTOT+SDT1+SDT2
92 W !,$P(SDD0,U,2),?7,$P(SDD0,U,4),?40,$J(SDT1,10),?55,$J(SDT2,10),?70,$J((SDT1+SDT2),10) Q
93 ;
94DXHD ;Diagnosis sub-header
95 Q:SDOUT W !!,"Diagnosis",?43,"Primary",?56,"Secondary",?75,"Total",!,"------------------------------------",?40,"----------",?55,"----------",?70,"----------" Q
96 ;
97PROC ;Print procedure information
98 D:$Y>(IOSL-8) HDR() Q:SDOUT D PROCHD I '$D(^TMP("SCRPW",$J,SDIV,1,SDS,"PROC")) W !!?12,"(No procedure information identified)" Q
99 S (SDT,SDTOT)="" F S SDT=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PROCTOT",SDT),-1) Q:SDT=""!SDOUT S SDP=0 F S SDP=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PROCTOT",SDT,SDP)) Q:'SDP!SDOUT D PROC1
100 Q:SDOUT
101 W !?12,"===================================",?55,"==========",!?12,"PROCEDURE TOTAL:",?55,$J(SDTOT,10) Q
102 ;
103PROC1 ;D:$Y>(IOSL-6) HDR(),PROCHD Q:SDOUT S SDP0=^ICPT(SDP,0),SDTOT=SDTOT+SDT W !?12,$P(SDP0,U),?18,$P(SDP0,U,2),?55,$J(SDT,10) Q
104 N CPTCODE,CPTTEXT,SDMOD,SDMODQTY
105 D:$Y>(IOSL-6) HDR(),PROCHD Q:SDOUT
106 S SDP0=$$CPT^ICPTCOD(SDP,,1)
107 Q:SDP0'>0
108 S CPTCODE=$P(SDP0,U,2)
109 S CPTTEXT=$P(SDP0,U,3)
110 S SDTOT=SDTOT+SDT
111 ;print procedure, desc, quantity
112 I LINEFLAG W !
113 W !?12,CPTCODE,?18,CPTTEXT,?55,$J(SDT,10)
114 S LINEFLAG=1
115 ;build array to hold ranked modifiers
116 K ^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",2)
117 S SDMOD=""
118 S SDPROC=SDP
119 F S SDMOD=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",SDPROC,SDMOD)) Q:SDMOD="" D
120 . S SDMODQTY=$G(^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",SDPROC,SDMOD))
121 . S ^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",2,SDMODQTY,SDMOD)=""
122 . Q
123 ; loop through ranked modifiers
124 S SDMODQTY=""
125 F S SDMODQTY=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",2,SDMODQTY),-1) Q:SDMODQTY="" D
126 . S SDMOD=""
127 . F S SDMOD=$O(^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",2,SDMODQTY,SDMOD),-1) Q:SDMOD="" D
128 .. D:$Y>(IOSL-6) HDR(),PROCHD Q:SDOUT
129 .. N MODINFO,MODCODE,MODTEXT,SDMQTY2
130 .. S MODINFO=$$MOD^ICPTMOD(SDMOD,"I",,1)
131 .. I +MODINFO'>0 Q
132 .. S MODCODE=$P(MODINFO,"^",2)
133 .. ; format for printing
134 .. S MODCODE=$S($L(MODCODE)=1:" "_MODCODE,1:" "_MODCODE)
135 .. S MODTEXT=$E($P(MODINFO,"^",3),1,32)
136 .. ;print modifier, desc, and quantity
137 .. S SDMQTY2="-"_SDMODQTY
138 .. W !,?13,"-",MODCODE,?18,MODTEXT,?55,$J(SDMQTY2,10)
139 .. Q
140 . S LINEFLAG=1
141 . Q
142 K ^TMP("SCRPW",$J,SDIV,1,SDS,"PROC",2)
143 Q
144 ;
145PROCHD S LINEFLAG=0 Q:SDOUT W !!?12,"Procedures/Modifiers",?60,"Total",!?12,"--------------------------------------",?55,"----------" Q
146 ;
147NONE ;List items with no activity
148 S SDS=0 F S SDS=$O(SD("LIST",SDS)) Q:'SDS!SDOUT I '$D(^TMP("SCRPW",$J,SDIV,1,SDS)) S SDN=1 D HDR("1N") Q
149 I $G(SDN) S SDS=0 F S SDS=$O(SD("LIST",SDS)) Q:'SDS!SDOUT I '$D(^TMP("SCRPW",$J,SDIV,1,SDS)) D:$Y>(IOSL-4) HDR("N") Q:SDOUT D NO1
150 Q
151 ;
152NO1 W !!,"No activity found for ",$S(SD("CAT")="C":"clinic",SD("CAT")="P":"provider",1:"stop code"),": ",$$SNAME() Q
Note: See TracBrowser for help on using the repository browser.