source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOCIDC8.m@ 1476

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

initial load of WorldVistAEHR

File size: 6.6 KB
Line 
1PSOCIDC8 ;BIR/LE - continuation of activity log corrections ;2/28/05 12:50pm
2 ;;7.0;OUTPATIENT PHARMACY;**239,250**;DEC 1997
3 ;External reference to ^XUSEC supported by DBIA 10076
4 ;External reference to $$PROD^XUPROD(1) supported by DBIA 4440
5 ;External references L and UL^PSSLOCK supported by DBIA 2789
6 ;
7CHECK ;
8 Q:'$D(^PSRX(RXP,"A",0))&('$D(^PSRX(RXP,"COPAY",0)))
9 N PSOMSG,PSONTIM,PSOCHECK,SEQ,CSEQ,CSEQ2
10 S (PSOCHECK,SEQ,CSEQ)=0
11 I $D(^PSRX(RXP,"A",0)) F S SEQ=$O(^PSRX(RXP,"A",SEQ)) Q:SEQ="" I $G(^PSRX(RXP,"A",SEQ,0))["BKGD CIDC" S PSOCHECK=1
12 I $D(^PSRX(RXP,"COPAY",0)) F S CSEQ=$O(^PSRX(RXP,"COPAY",CSEQ)) Q:CSEQ="" I $G(^PSRX(RXP,"COPAY",CSEQ,0))["BKGD CIDC" S PSOCHECK=1
13 Q:'PSOCHECK
14CHECK1 ;
15 D PSOL^PSSLOCK(RXP) S PSONTIM=$G(PSONTIM)+1 G CHECK1:'$G(PSOMSG)&($G(PSONTIM)<10)
16 I '+$G(PSOMSG) S:'$G(FIXONE) ^XTMP(NAMSP,0,"LOCKED RX",RXP)="" S:('+$G(PSOMSG)&($G(FIXONE))) PSOFONE=1 W:$G(FIXONE) !,"Cannot lock Rx for correction.",!! Q
17 ;
18 I $D(^XTMP(NAMSP,0,"STOP")) S $P(^XTMP(NAMSP,0,"LAST"),"^",3)=$O(^PSRX("AD",PSODT),-1),$P(^XTMP(NAMSP,0,"LAST"),"^",4)=$O(^PSRX(RXP),-1) Q
19 N AFLG,CFLG,CDAT,CHSEQ,ADATA,CDATA,DATA,ENTRY,EDAT,EFILL,ESEQ,MDATA,NEXT
20 ;
21 I $D(^PSRX(RXP,"A",0)) D
22 . S SEQ=0 F S SEQ=$O(^PSRX(RXP,"A",SEQ)) Q:SEQ="" I $G(^PSRX(RXP,"A",SEQ,0))["BKGD CIDC" D Q:AFLG
23 .. M ^XTMP(NAMSP,"A",PSODFN,RXP,"A")=^PSRX(RXP,"A") S AFLG=1
24 .. I $D(^PSRX(RXP,"COPAY")) M ^XTMP(NAMSP,"C",PSODFN,RXP,"COPAY")=^PSRX(RXP,"COPAY")
25 .. E S ^XTMP(NAMSP,"C",PSODFN,RXP)="No previous copay activity log in file 52"
26 D:$G(AFLG) ACTLOG
27 ;
28 K CDATA S CFLG=0
29 I $D(^PSRX(RXP,"COPAY",0)) D
30 . S CSEQ=0 F S CSEQ=$O(^PSRX(RXP,"COPAY",CSEQ)) Q:CSEQ="" I $G(^PSRX(RXP,"COPAY",CSEQ,0))["BKGD CIDC" D Q:CFLG
31 .. I '$D(^XTMP(NAMSP,"C",PSODFN,RXP))&(^PSRX(RXP,"COPAY",CSEQ,0)'["CIDC CLEANUP") M ^XTMP(NAMSP,"C",PSODFN,RXP,"COPAY")=^PSRX(RXP,"COPAY")
32 .. S CFLG=1
33 D:$G(CFLG)!$G(AFLG) CPLOG
34 D PSOUL^PSSLOCK(RXP)
35 Q
36 ;
37ACTLOG ;ACTIVITY LOG
38 S (CHSEQ,SEQ)=0
39 F S SEQ=$O(^PSRX(RXP,"A",SEQ)) Q:SEQ="" S ENTRY=$G(^PSRX(RXP,"A",SEQ,0)) I ENTRY'="" D
40 . I ENTRY'["BKGD CIDC" S CHSEQ=CHSEQ+1,CDATA(CHSEQ)=ENTRY Q
41 . S MDATA($P(ENTRY,"^"),$P(ENTRY,"^",4),SEQ)=""
42 ;
43 ;Q:'$D(CDATA)&('$D(MDATA))
44 ;
45 ;***************************** FOR LIVE RUN
46 I $D(CDATA)!($D(MDATA)) D
47 .I $D(^PSRX(RXP,"A")) K ^PSRX(RXP,"A")
48 .Q:'$D(CDATA)
49 .S (CHSEQ,SEQ)=0 F S SEQ=$O(CDATA(SEQ)) Q:SEQ="" S ^PSRX(RXP,"A",SEQ,0)=CDATA(SEQ),CHSEQ=SEQ
50 .S ^PSRX(RXP,"A",0)="^52.3DA^"_CHSEQ_"^"_CHSEQ
51 .S ^XTMP(NAMSP,"LOG",PSONAM,PSODFN,RXP)=""
52 ;*****************************
53 ;***---------------------------------------->>>>>>>>>> UN-COMMENT NEXT 3 LINES FOR TESTING ONLY AND COMMENT LIVE RUN
54 ;S (CHSEQ,SEQ)=0 F S SEQ=$O(CDATA(SEQ)) Q:SEQ="" S ^XTMP("TST "_NAMSP,RXP,"A",SEQ,0)=CDATA(SEQ),CHSEQ=SEQ
55 ;S ^XTMP("TST "_NAMSP,RXP,"A",0)="^52.3DA^"_CHSEQ_"^"_CHSEQ
56 ;S ^XTMP("TST "_NAMSP,"LOG",PSONAM,PSODFN,RXP)=""
57 ;
58 Q
59 ;
60CPLOG ;COPAY ACTIVITY LOG
61 S (EDAT,EFILL,ESEQ)="",(CHSEQ,CSEQ2)=0
62 I '$D(^PSRX(RXP,"COPAY"))&($D(MDATA)) D G SKP2
63 . F S EDAT=$O(MDATA(EDAT)) Q:EDAT="" F S EFILL=$O(MDATA(EDAT,EFILL)) Q:EFILL="" F S ESEQ=$O(MDATA(EDAT,EFILL,ESEQ)) Q:ESEQ="" D
64 .. S CHSEQ=CHSEQ+1,CDATA(CHSEQ)=EDAT_"^R^.5^"_EFILL_"^CIDC CLEANUP"
65 ;
66 F S CSEQ2=$O(^PSRX(RXP,"COPAY",CSEQ2)) Q:CSEQ2="" D
67 . S DATA=^PSRX(RXP,"COPAY",CSEQ2,0),CDAT=$P(DATA,"^")
68 . I DATA["-BKGD CIDC" S $P(DATA,"^",5)="CIDC CLEANUP"
69SKP .;
70 . I '$G(EDAT)&($D(MDATA)) S (EDAT,EFILL,ESEQ)="",EDAT=$O(MDATA(EDAT)),EFILL=$O(MDATA(EDAT,EFILL)),ESEQ=$O(MDATA(EDAT,EFILL,ESEQ))
71 . I EDAT<CDAT&(EDAT'="") S CHSEQ=CHSEQ+1,CDATA(CHSEQ)=EDAT_"^R^.5^"_EFILL_"^CIDC CLEANUP" K MDATA(EDAT,EFILL,ESEQ) S EDAT="" G SKP
72 . S CHSEQ=CHSEQ+1,CDATA(CHSEQ)=^PSRX(RXP,"COPAY",CSEQ2,0)
73 . I CDATA(CHSEQ)["BKGD CIDC" S $P(CDATA(CHSEQ),"^",5)="CIDC CLEANUP"
74 ;
75 I $D(MDATA) S (EDAT,EFILL,ESEQ)="" F S EDAT=$O(MDATA(EDAT)) Q:EDAT="" F S EFILL=$O(MDATA(EDAT,EFILL)) Q:EFILL="" F S ESEQ=$O(MDATA(EDAT,EFILL,ESEQ)) Q:ESEQ="" D
76 . S CHSEQ=CHSEQ+1,CDATA(CHSEQ)=EDAT_"^R^.5^"_EFILL_"^CIDC CLEANUP"
77SKP2 ;
78 Q:'$D(CDATA)
79 ;
80 ;***************************** FOR LIVE RUN
81 I $D(^PSRX(RXP,"COPAY")) K ^PSRX(RXP,"COPAY")
82 S (CSEQ2,CHSEQ)=0 F S CSEQ2=$O(CDATA(CSEQ2)) Q:CSEQ2="" S ^PSRX(RXP,"COPAY",CSEQ2,0)=CDATA(CSEQ2),CHSEQ=CSEQ2
83 S ^PSRX(RXP,"COPAY",0)="^52.0107DA^"_CHSEQ_"^"_CHSEQ
84 S ^XTMP(NAMSP,"LOG",PSONAM,PSODFN,RXP)=""
85 ;*****************************
86 ;***---------------------------------------->>>>>>>>>>> UN-COMMENT NEXT 3 LINES FOR TESTING ONLY AND COMMENT LIVE RUN
87 ;S (CSEQ2,CHSEQ)=0 F S CSEQ2=$O(CDATA(CSEQ2)) Q:CSEQ2="" S ^XTMP("TST "_NAMSP,RXP,"COPAY",CSEQ2,0)=CDATA(CSEQ2),CHSEQ=CSEQ2
88 ;S ^XTMP("TST "_NAMSP,RXP,"COPAY",0)="^52.0107DA^"_CHSEQ_"^"_CHSEQ
89 ;S ^XTMP("TST "_NAMSP,"LOG",PSONAM,PSODFN,RXP)=""
90 Q
91 ;
92SITE ; SET UP VARIABLES NEEDED BY BILLING
93 S PSOSITE=$S(YY=0:$P(^PSRX(RXP,2),"^",9),1:$P($G(^PSRX(RXP,1,YY,0)),"^",9))
94 Q:PSOSITE=""
95 S PSOPAR=$G(^PS(59,PSOSITE,1))
96 S PSOPAR7=$G(^PS(59,PSOSITE,"IB"))
97 S PSOSITE7=$P($G(^PS(59,PSOSITE,"IB")),"^")
98 Q
99 ;
100MAIL3(MSG) ;management mail message
101 S PSOINST=$P($G(^DIC(4,+$P($G(^XMB(1,1,"XUS")),"^",17),99)),"^")
102 D NOW^%DTC S Y=% D DD^%DT S PSOEND=Y
103 K PSOTEXT
104 S:$G(DUZ) XMY(DUZ)=""
105 ;S XMY("ELLZEY.LINDA@FORUM.VA.GOV")=""
106 S:$$PROD^XUPROD(1) XMY("ELLZEY.LINDA@FORUM.VA.GOV")=""
107 S XMDUZ="PSO*7*239 "_JOBN
108 S XMSUB="STATION "_$G(PSOINST)
109 S XMSUB=XMSUB_$S($$PROD^XUPROD(1):" (Prod)",1:" (Test)")
110 S XMSUB=XMSUB_" Activity log and Copay Activity log correction "
111 S PSOTEXT(1)=""
112 S PSOTEXT(2)="Started "_PSOSTART
113 S PSOTEXT(3)=""
114 S PSOTEXT(4)=" "_MSG
115 S PSOTEXT(5)=""
116 S PSOTEXT(6)="NO FURTHER ACTION REQUIRED."
117 S XMTEXT="PSOTEXT(" N DIFROM D ^XMD K XMDUZ,XMTEXT,XMSUB,PSOEND
118 Q
119 ;
120MAIL ;
121 D NOW^%DTC S Y=% D DD^%DT N PSOCXPDA,PSOTEXT,XMY,XMTEXT,PSORXP,PSONCNT,PSOEND2,PSOEND
122 S PSOEND=Y,PSOEND2=$$FMTE^XLFDT(%,"1PS")
123 I $G(DUZ) S XMY(DUZ)=""
124 S XMDUZ="PSO*7*239 "_JOBN
125 S XMSUB="Outpatient Pharmacy PSO*7*239 "_JOBN
126 ;S XMY("ELLZEY.LINDA@FORUM.VA.GOV")=""
127 F PSOCXPDA=0:0 S PSOCXPDA=$O(^XUSEC("PSO COPAY",PSOCXPDA)) Q:'PSOCXPDA S XMY(PSOCXPDA)=""
128 I $O(XMY(""))="" Q ; no recipients for mail message
129 S PSOTEXT(1)="The "_JOBN_" job for the Outpatient Pharmacy"
130 S PSOTEXT(2)="patch (PSO*7*239) started "_PSOSTART
131 S PSOTEXT(3)="and completed "_PSOEND_"."
132 S PSOTEXT(4)=" ",(PSORXP,PSONCNT)=""
133 S PSOTEXT(5)=" "
134 S PSOTEXT(6)=" "
135 I $D(^XTMP("PSOCIDC7",0,"LOCKED RX")) D
136 . F S PSORXP=$O(^XTMP("PSOCIDC7",0,"LOCKED RX",PSORXP)) Q:PSORXP="" S PSONCNT=PSONCNT+1
137 . Q:'$G(PSONCNT)>0
138 . S PSOTEXT(5)="There were "_PSONCNT_" locked Rx(s) that could not be processed."
139 . S PSOTEXT(6)="From programmer's mode, type D LOCKED^PSOCIDC9 for a report."
140 S PSOTEXT(7)=" "
141 ;
142 S XMTEXT="PSOTEXT(" N DIFROM D ^XMD K XMDUZ,XMTEXT,XMSUB
143 Q
144 ;
Note: See TracBrowser for help on using the repository browser.