source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOBPSR1.m@ 1195

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

initial load of WorldVistAEHR

File size: 6.6 KB
Line 
1PSOBPSR1 ;BHM/LE - continued Ignored Claims Report ;03/01/07
2 ;;7.0;OUTPATIENT PHARMACY;**260**;13 Feb 97;Build 84
3 ;External reference to File ^PS(55 supported by DBIA 2228
4 ;External reference to $$GET1^DIQ is supported by DBIA 2056
5 ;External reference to ^VADPT is supported by DBIA 10061
6 ;External reference to ^XLFDT is supported by DBIA 10103
7 ;External reference to ^%ZISC is supported by DBIA 10089
8 ;
9EN N CLOSE,CDATE,DFN,DRG,RXIEN,PAG,PCNT,PRTD,PNAM,I,II,J,Y,X,XX,S1,S2,S3,S4,S5,FCNT,CBYI
10 N SP1,SP2,SEQ2,CINFO,RDATE,RSEQ,PSORX,RXINFO,DNAMI,CDIV,CDIVN,OCDIV,RXNUMB,PSORXN,RXE
11 U IO K ^TMP("PSOBPSRP",$J),^TMP("PSOBPSRC",$J)
12 S (SP1,SP2)="",$P(SP1,"=",81)="",$P(SP2,"-",81)=""
13 ;
14 ; - Loop through reject dates xref
15 S (RXIEN,PCNT,FCNT,PRTD)=0 K DIRUT
16 S RDATE=PSOSD
17 ;
18DATE ;
19 S RDATE=$O(^PSRX("REJDAT",RDATE)) G NEXT:RDATE=""!(RDATE>PSOED)
20RX ;
21 S RXIEN=$O(^PSRX("REJDAT",RDATE,RXIEN)) G DATE:RXIEN=""
22 S (DFN,DRG,PNAM,DNAM,DNAMI,RXE)=""
23 K RXINFO D GETS^DIQ(52,RXIEN_",",".01;2;6","IE","RXINFO")
24 S PNAM=$G(RXINFO(52,RXIEN_",",2,"E")),DNAM=$G(RXINFO(52,RXIEN_",",6,"E"))
25 S DFN=$G(RXINFO(52,RXIEN_",",2,"I")),DNAMI=$G(RXINFO(52,RXIEN_",",6,"I"))
26 S RXE=$G(RXINFO(52,RXIEN_",",.01,"E"))_" "
27 I '$G(PSOAPT),'$D(PSOPT(DFN)) G RX ;user selected specific patients
28 I '$G(PSODRUG),'$D(PSODRG(DNAMI)) G RX
29 ;
30 ;look for ignored rejects
31 S SEQ2=0 F S SEQ2=$O(^PSRX(RXIEN,"REJ",SEQ2)) Q:'SEQ2&(SEQ2'?1N.N) D
32 . S (CDATE,CBY,CBYI,CFILL,CDIV)=""
33 . K CLOSE D GETS^DIQ(52.25,SEQ2_","_RXIEN_",","5;10;11;12","IE","CLOSE")
34 . S CDATE=$G(CLOSE(52.25,SEQ2_","_RXIEN_",",10,"I"))
35 . S CFILL=$G(CLOSE(52.25,SEQ2_","_RXIEN_",",5,"I"))
36 . S CDIV=$$RXSITE^PSOBPSUT(RXIEN,CFILL)
37 . I '$G(PSOSIT)&'$D(PSODIV(CDIV)) Q
38 . I $G(CLOSE(52.25,SEQ2_","_RXIEN_",",12,"I"))=6,(CDATE'<PSOSD&(CDATE'>PSOED)) D
39 . . S CBY=$G(CLOSE(52.25,SEQ2_","_RXIEN_",",11,"E"))
40 . . S CBYI=$G(CLOSE(52.25,SEQ2_","_RXIEN_",",11,"I"))
41 . . I '$G(PSOUSER),'$D(PSOU(CBYI)) Q ;user selected specific user for "ignored by" column in report
42 . . D SET
43 G RX
44 ;
45NEXT ; - If not Sorting (already printed), SKIP, otherwise, print the report
46 I '$D(^TMP("PSOBPSRP")) G NDTP
47 S (S1,S2,S3,DFN,RSEQ,PSORX,PSORXN,RXNUMB,CDIV,OCDIV,CDIVN)=""
48 F S CDIV=$O(^TMP("PSOBPSRP",$J,CDIV)) Q:CDIV="" D Q:$D(DIRUT)
49 . F S S1=$O(^TMP("PSOBPSRP",$J,CDIV,S1)) Q:S1="" D Q:$D(DIRUT)
50 . . F S S2=$O(^TMP("PSOBPSRP",$J,CDIV,S1,S2)) Q:S2="" D Q:$D(DIRUT)
51 . . . F S S3=$O(^TMP("PSOBPSRP",$J,CDIV,S1,S2,S3)) Q:S3="" D Q:$D(DIRUT)
52 . . . . F S DFN=$O(^TMP("PSOBPSRP",$J,CDIV,S1,S2,S3,DFN)) Q:DFN="" D Q:$D(DIRUT)
53 . . . . . F S PSORXN=$O(^TMP("PSOBPSRP",$J,CDIV,S1,S2,S3,DFN,PSORXN)) Q:PSORXN="" D Q:$D(DIRUT)
54 . . . . . . F S RSEQ=$O(^TMP("PSOBPSRP",$J,CDIV,S1,S2,S3,DFN,PSORXN,RSEQ)) Q:RSEQ="" D Q:$D(DIRUT)
55 . . . . . . . I $Y>(IOSL-7)&($E(IOST)="C") D HDR I $D(DIRUT) Q
56 . . . . . . . I $Y>(IOSL-12)&($E(IOST)'="C") D HDR I $D(DIRUT) Q
57 . . . . . . . S (RXNUMB,PSORX)="",RXNUMB=$E(PSORXN,1,$L(PSORXN)-1),PSORX=$O(^PSRX("B",RXNUMB,PSORX))
58 . . . . . . . D PRINT(DFN,PSORX)
59 . . . I '$D(DIRUT),S2'=0,$O(^TMP("PSOBPSRP",$J,CDIV,S1,S2))'="" W SP2
60 . . I '$D(DIRUT),$O(^TMP("PSOBPSRP",$J,CDIV,S1))'="" W !,SP1
61 G CLOSE:$D(DIRUT)
62 ;
63NDTP I 'PRTD D HDR W !!?18,"********** NO DATA TO PRINT **********"
64 I $G(PCNT) D
65 . W !,SP1
66 . W !,"Total: ",PCNT," patient",$S(PCNT>1:"s",1:"")
67 . W " and ",FCNT," prescription fill",$S(FCNT>1:"s",1:""),"."
68 ;
69CLOSE ;
70 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
71END K ^TMP("PSOBPSRP",$J),^TMP("PSOBPSRC",$J)
72 K PSOAPT,PSODRUG,PSOUSER,PSOU,PSODRG,PSOPT,PSOSRT,PSOED,PSOSD,PSODIV,PSOSIT
73 Q
74 ;
75SET ;
76 S (S1,S2,S3)=0
77 F I=1:1:$L(PSOSRT,",") D
78 . S Y=$P(PSOSRT,",",I)
79 . S @("S"_I)=$S(Y=1:PNAM,Y=2:DNAM,Y=3:CBY)
80 S ^TMP("PSOBPSRP",$J,CDIV,S1,S2,S3,DFN,RXE,SEQ2)=""
81 Q
82 ;
83PRINT(DFN,RXIEN) ; - Print
84 ;Input: DFN-Patient;RXIEN=Prescription IEN
85 N X,XX,K,PNAM,PSSN,II,J,STR,CCOM,PMES,CBY,CREAS,CDAT,CFILL,RXNUM,DNAM,CINFO
86 S (CDAT,CREAS,CBY,DNAM,PNAM,PMES,PSSN,CCOM,CINFO,RXNUM)=""
87 ;
88 I OCDIV'=CDIV!(OCDIV="") D HDR I $D(DIRUT) Q
89 S OCDIV=CDIV
90 ;
91 D DEM^VADPT S PSSN=$P($G(VADM(2)),"^",2) K VADM
92 K RXINFO D GETS^DIQ(52,RXIEN_",",".01;2;6","EI","RXINFO")
93 S PNAM=RXINFO(52,RXIEN_",",2,"E"),DNAM=RXINFO(52,RXIEN_",",6,"E")
94 D GETS^DIQ(52.25,RSEQ_","_RXIEN_",","5;10;11;12;2;13","IE","CINFO")
95 S:$D(RXINFO(52,RXIEN_",",.01,"E")) RXNUM=RXINFO(52,RXIEN_",",.01,"E")
96 S:$D(CINFO(52.25,RSEQ_","_RXIEN_",",10,"I")) CDAT=CINFO(52.25,RSEQ_","_RXIEN_",",10,"I")
97 S CDAT=$$DT(CDAT)
98 S:$D(CINFO(52.25,RSEQ_","_RXIEN_",",12,"I")) CREAS=CINFO(52.25,RSEQ_","_RXIEN_",",12,"E")
99 S:$D(CINFO(52.25,RSEQ_","_RXIEN_",",11,"E")) CBY=CINFO(52.25,RSEQ_","_RXIEN_",",11,"E")
100 S:$D(CINFO(52.25,RSEQ_","_RXIEN_",",2,"E")) PMES=CINFO(52.25,RSEQ_","_RXIEN_",",2,"E")
101 D TEXT(.PMES,PMES,65)
102 S:$D(CINFO(52.25,RSEQ_","_RXIEN_",",13,"E")) CCOM=CINFO(52.25,RSEQ_","_RXIEN_",",13,"E")
103 D TEXT(.CCOM,CCOM,65)
104 S:$D(CINFO(52.25,RSEQ_","_RXIEN_",",5,"I")) CFILL=CINFO(52.25,RSEQ_","_RXIEN_",",5,"I")
105 ;
106 W !,RXNUM_"/"_CFILL,?15,$E(DNAM,1,21),?37,$E(PNAM,1,13)_"("_$P(PSSN,"-",3)_")",?57,CDAT,?66,$E(CBY,1,14)
107 S II="" F S II=$O(CCOM(II)) Q:II="" D
108 . W:II=1 !," Comments: "
109 . W:$D(CCOM(II)) ?15,CCOM(II),!
110 S II="" F S II=$O(PMES(II)) Q:II="" D
111 . W:II=1 "Payer Message: "
112 . W:$D(PMES(II)) ?15,PMES(II),!
113 ;
114 S:'$D(^TMP("PSOBPSRC",$J,DFN)) PCNT=PCNT+1 S ^TMP("PSOBPSRC",$J,DFN)=""
115 ;
116 S PRTD=1,FCNT=FCNT+1
117 Q
118 ;
119TEXT(TEXT,STR,L) ; Formats STR into TEXT array, lines lenght = L
120 N J,WORD,K S K=+$O(TEXT(""),-1) S:'K K=1
121 F J=1:1:$L(STR," ") D
122 . S WORD=$P(STR," ",J) I ($L($G(TEXT(K))_WORD))>L S K=K+1
123 . S TEXT(K)=$G(TEXT(K))_WORD_" "
124 Q
125 ;
126HDR ; - Prints the Header
127 N X,DIR,CDIVN S PAG=$G(PAG)+1
128 S CDIVN=$$GET1^DIQ(59,$G(CDIV)_",",".01")
129 I PAG>1,$E(IOST)="C" D Q:$D(DIRUT)
130 . S DIR(0)="E",DIR("A")=" Press ENTER to Continue or ^ to Exit" D ^DIR
131 ;
132 W @IOF,"Ignored Rejects Report",?71,"Page: ",$J(PAG,3)
133 W !,"Sorted by",$$SRT(PSOSRT),?48,"Division: ",CDIVN
134 W !,"Date Range: "_$$DT(PSOSD+1\1)_" - "_$$DT(PSOED\1)
135 W ?48,"Run Date: "_$$FMTE^XLFDT($$NOW^XLFDT())
136 S X="",$P(X,"-",81)="" W !,X
137 W !,"RX#/FILL",?15,"DRUG",?37,"PATIENT",?56,"IGNORE DT",?66,"IGNORED BY"
138 W !,"--------------",?15,"---------------------",?37,"------------------",?56,"---------",?66,"--------------"
139 Q
140 ;
141SRT(ST) ; - Convert the "2,1" (example) to "DRUG,PATIENT"
142 ;Input: ST-String with the Sorting fields by number
143 ;Output: ST-String with the Sorting fields by name
144 N I,X,STR,FLD
145 S STR="PATIENT^DRUG^USER"
146 F I=1:1:$L(ST,",") D
147 . S FLD=+$P(ST,",",I),X=$P(STR,"^",FLD)
148 . S $P(ST,",",I)=" "_X
149 Q ST
150 ;
151DT(DT) ; - Convert FM Date to MM/DD/YYYY
152 I 'DT Q ""
153 I '(DT#10000) Q (1700+$E(DT,1,3))
154 I '(DT#100) Q $E(DT,4,5)_"/"_(1700+$E(DT,1,3))
155 Q $E(DT,4,5)_"/"_$E(DT,6,7)_"/"_$E((1700+$E(DT,1,3)),3,4)
156 ;
Note: See TracBrowser for help on using the repository browser.