source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOTPCAN.m@ 677

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

initial load of FOIAVistA 6/30/08 version

File size: 7.6 KB
Line 
1PSOTPCAN ;BIR/RTR - TPB Utility routine ;08/23/03
2 ;;7.0;OUTPATIENT PHARMACY;**146,153,163,227**;DEC 1997
3 ;External reference to PS(55 supported by DBIA 2228
4 ;External reference to VA(200 supported by DBIA 224
5 ;
6 ;Check Rx being DC'd, if it's a TPB Rx, check to inactivate patient
7 ;Called from all DC actions
8CAN(PSOTPRCX) ;
9 Q ; placed out of order by PSO*7*227
10 I '$G(PSOTPRCX) Q
11 N PSOTPRC
12 S PSOTPRC=$P($G(^PSRX(PSOTPRCX,0)),"^",2)
13 I '$G(PSOTPRC) Q
14 I '$P($G(^PSRX(PSOTPRCX,"TPB")),"^") Q
15 I '$D(^PS(52.91,PSOTPRC,0)) Q
16 I $P($G(^PS(52.91,PSOTPRC,0)),"^",3),$P($G(^(0)),"^",3)'>DT Q
17 ;Patient is active in the TPB File, and TPB Rx is being canceled
18 I PSOTPRC'=$P($G(^PSRX(PSOTPRCX,0)),"^",2) Q
19 N PSOTPCSS,PSOTCXFL,PSOTC1,PSOTC2,PSOTC3,X1,X2,DA,DR,DIE,X,Y
20 S PSOTCXFL=0
21 S X1=DT,X2=-1 D C^%DTC S PSOTC3=X
22 F PSOTC1=PSOTC3:0 S PSOTC1=$O(^PS(55,PSOTPRC,"P","A",PSOTC1)) Q:'PSOTC1!(PSOTCXFL) S PSOTC2="" F S PSOTC2=$O(^PS(55,PSOTPRC,"P","A",PSOTC1,PSOTC2)) Q:PSOTC2=""!(PSOTCXFL) D
23 .I $P($G(^PSRX(PSOTC2,0)),"^",2)'=PSOTPRC Q
24 .S PSOTPCSS=$P($G(^PSRX(PSOTC2,"STA")),"^")
25 .I PSOTPCSS'=0,PSOTPCSS'=1,PSOTPCSS'=2,PSOTPCSS'=3,PSOTPCSS'=4,PSOTPCSS'=5,PSOTPCSS'=16 Q
26 .I $P($G(^PSRX(PSOTC2,"TPB")),"^"),$P($G(^(2)),"^",6)'<DT S PSOTCXFL=1
27 I 'PSOTCXFL K DA,DIE,DR S DA=PSOTPRC,DIE="^PS(52.91,",DR="2////"_DT_";3////"_6 D ^DIE K DIE,DA,DR
28 Q
29 ;
30MARK ;Mark Rx as TPB Rx if applicable
31 N PSOTPODE,PSOZTRX
32 I '$G(PSOX("IRXN")) Q
33 I '$D(^PSRX(PSOX("IRXN"),0)) Q
34 I '$G(PSOTPBFG) Q
35 ;I $G(PSOFDR) Q
36 S PSOTPODE=$G(^PSRX(PSOX("IRXN"),0))
37 I '$P(PSOTPODE,"^",2)!('$P(PSOTPODE,"^",3))!('$P(PSOTPODE,"^",4)) Q
38 S PSOZTRX=$P($G(^PS(53,+$P(PSOTPODE,"^",3),0)),"^") I $$UP^XLFSTR(PSOZTRX)'="NON-VA" Q
39 I '$P($G(^VA(200,+$P(PSOTPODE,"^",4),"TPB")),"^") Q
40 I $P($G(^VA(200,+$P(PSOTPODE,"^",4),"TPB")),"^",5)'=0 Q
41 I '$D(^PS(52.91,+$P(PSOTPODE,"^",2),0)) Q
42 I $P($G(^PS(52.91,+$P(PSOTPODE,"^",2),0)),"^",3),$P($G(^(0)),"^",3)'>DT Q
43 ;Hard setting, to avoid DIE kiling any needed variables, no cross references on field, if added, need to use FileMan here
44 S $P(^PSRX(PSOX("IRXN"),"TPB"),"^")=1
45 Q
46MARKV ;Mark from Verify action
47 N PSOTPV1,PSOTPV2
48 I '$G(PSONVLP) Q
49 I '$D(^PSRX(PSONVLP,0)) Q
50 I '$G(PSOTPBFG) Q
51 ;I $G(PSOFDR) Q
52 S PSOTPV1=$G(^PSRX(PSONVLP,0))
53 I '$P(PSOTPV1,"^",2)!('$P(PSOTPV1,"^",3))!('$P(PSOTPV1,"^",4)) Q
54 S PSOTPV2=$P($G(^PS(53,+$P(PSOTPV1,"^",3),0)),"^") I $$UP^XLFSTR(PSOTPV2)'="NON-VA" Q
55 I '$P($G(^VA(200,+$P(PSOTPV1,"^",4),"TPB")),"^") Q
56 I $P($G(^VA(200,+$P(PSOTPV1,"^",4),"TPB")),"^",5)'=0 Q
57 I '$D(^PS(52.91,+$P(PSOTPV1,"^",2),0)) Q
58 I $P($G(^PS(52.91,+$P(PSOTPV1,"^",2),0)),"^",3),$P($G(^(0)),"^",3)'>DT Q
59 S $P(^PSRX(PSONVLP,"TPB"),"^")=1
60 Q
61RXPAT ;Sets Rx patient status to null
62 N PSOZZTRX
63 I $G(X),$G(X)'>DT D
64 .S PSOZZTRX=$P($G(^PS(53,+$P($G(^PS(55,DA,"PS")),"^"),0)),"^") S PSOZZTRX=$$UP^XLFSTR(PSOZZTRX) I PSOZZTRX="NON-VA" S $P(^PS(55,DA,"PS"),"^")=""
65 Q
66SET(PSOTPPST) ;Pass in DFN on a hard set of INACTIVATION OF BENEFIT DATE
67 N PSOZXTRX
68 I $P($G(^PS(52.91,PSOTPPST,0)),"^",3),$P($G(^(0)),"^",3)'>DT S PSOZXTRX=$P($G(^PS(53,+$P($G(^PS(55,PSOTPPST,"PS")),"^"),0)),"^") I $$UP^XLFSTR(PSOZXTRX)="NON-VA" S $P(^PS(55,PSOTPPST,"PS"),"^")=""
69 Q
70PCAP(PSOPAPPT) ;Find nearest Primary Care appointment
71 Q "TODAY AT NOON"
72 ;
73PDIR(PSOTPEX) ;
74 Q:'$G(PSOTPEX)
75 N PSOTPEXS
76 S PSOTPEXT=0
77 S PSOTPEXS=$P($G(^DPT(PSOTPEX,0)),"^",9)
78 W !!?10,$C(7),$P($G(^DPT(PSOTPEX,0)),"^")_" ("_$E(PSOTPEXS,1,3)_"-"_$E(PSOTPEXS,4,5)_"-"_$E(PSOTPEXS,6,9)_")"
79 W !?10,"Patient is eligible for the Transitional Pharmacy Benefit!!"
80 W ! K DIR S DIR(0)="E",DIR("A")="Press <ret> to continue, '^' to exit" D ^DIR K DIR I Y'=1 S PSOTPEXT=1
81 Q
82VOPN ;
83 I '$G(PSOTPPEN) Q
84 I '$D(^PSRX(PSOTPPEN,0)) Q
85 N PSOTPPE3,PSOTPPE4,PSOTPPE5,PSOTPPE6,PSOTPPE7,PSOTPPE8
86 S PSOTPPE6=1
87 S PSOTPPE3=$P($G(^PSRX(PSOTPPEN,0)),"^",3),PSOTPPE4=$P($G(^PSRX(PSOTPPEN,0)),"^",4)
88VOPNX ;
89 I 'PSOTPPE4 S PSOTPPEX=1,PSOTPPE5(PSOTPPE6)="Unknown Provider!",PSOTPPE6=PSOTPPE6+1
90 I 'PSOTPPE3 S PSOTPPEX=1 S PSOTPPE5(PSOTPPE6)="Unknown Patient Status!",PSOTPPE6=PSOTPPE6+1
91 I PSOTPPE4,'$P($G(^VA(200,PSOTPPE4,"TPB")),"^") S PSOTPPE5(PSOTPPE6)="Provider is not flagged as a NON-VA PRESCRIBER!",PSOTPPE6=PSOTPPE6+1,PSOTPPEX=1
92 I PSOTPPE4,$P($G(^VA(200,PSOTPPE4,"TPB")),"^",5)'=0 S PSOTPPE5(PSOTPPE6)="Provider is not flagged as not being on exclusionary list!",PSOTPPE6=PSOTPPE6+1,PSOTPPEX=1
93 I PSOTPPE3 S PSOTPPE7=$P($G(^PS(53,PSOTPPE3,0)),"^") S PSOTPPE7=$$UP^XLFSTR(PSOTPPE7) I PSOTPPE7'="NON-VA" S PSOTPPE5(PSOTPPE6)="Rx Patient Status is not equal to 'NON-VA'!",PSOTPPE6=PSOTPPE6+1,PSOTPPEX=1
94 I $G(PSOTPPEX) D I $G(PSOTPPE9) S VALMSG="Cannot Verify through this option"
95 .W ! F PSOTPPE8=0:0 S PSOTPPE8=$O(PSOTPPE5(PSOTPPE8)) Q:'PSOTPPE8 W !,$G(PSOTPPE5(PSOTPPE8))
96 .K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
97 Q
98VOPNR ;
99 I '$G(PSOTPPEN) Q
100 I '$D(^PS(52.41,PSOTPPEN,0)) Q
101 N PSOTPPE3,PSOTPPE4,PSOTPPE5,PSOTPPE6,PSOTPPE7,PSOTPPE8
102 S PSOTPPE6=1
103 I $P(^PS(52.41,PSOTPPEN,0),"^",3)="RNW",$D(^PSRX(+$P(^PS(52.41,PSOTPPEN,0),"^",21),0)) S PSOTPPE3=$P($G(^PSRX(+$P(^PS(52.41,PSOTPPEN,0),"^",21),0)),"^",3) G NOREN
104 S PSOTPPE3=$P($G(^PS(55,+$P($G(^PS(52.41,PSOTPPEN,0)),"^",2),"PS")),"^")
105NOREN ;
106 S PSOTPPE4=$P($G(^PS(52.41,PSOTPPEN,0)),"^",5)
107 G VOPNX
108 ;
109DSPL(PSOTPWRN) ;
110 N DIR,PSOTPWR1,PSOTPWR2,PSOTPWR3
111 I '$G(PSOTPWRN) Q
112 I '$D(^PS(52.41,PSOTPWRN,0)) Q
113 I $P(^PS(52.41,PSOTPWRN,0),"^",3)="RNW",$D(^PSRX(+$P(^PS(52.41,PSOTPWRN,0),"^",21),0)) D Q
114 . S PSOTPWR1=$P($G(^PSRX(+$P(^PS(52.41,PSOTPWRN,0),"^",21),0)),"^",3)
115 . S PSOTPWR2=$P($G(^PS(53,+PSOTPWR1,0)),"^"),PSOTPWR3=$$UP^XLFSTR(PSOTPWR2)
116 . I PSOTPWR3="NON-VA" D
117 . . K DIR W !!,"This order has an Rx Patient Status of 'NON-VA'!",! K DIR S DIR(0)="E",DIR("A")="Press return to continue" D ^DIR K DIR
118 . . Q
119 . Q
120 S PSOTPWR1=$P($G(^PS(55,+$P($G(^PS(52.41,PSOTPWRN,0)),"^",2),"PS")),"^")
121 S PSOTPWR2=$P($G(^PS(53,+PSOTPWR1,0)),"^") S PSOTPWR3=$$UP^XLFSTR(PSOTPWR2)
122 I PSOTPWR3="NON-VA" D
123 .W !!,"This order has an Rx Patient Status of 'NON-VA'!",! K DIR S DIR(0)="E",DIR("A")="Press return to continue" D ^DIR K DIR
124 Q
125EXFLAG(PSOTPPX) ;Exit TPB RX option, reset TPG flag if necessary,
126 ;and possibly delete inactive date and reason code for patient in 52.91
127 I '$G(DT) S DT=$$DT^XLFDT
128 I '$G(PSOTPPX) Q
129 I '$D(^PS(52.91,PSOTPPX,0)) Q
130 I $E($P(^PS(52.91,PSOTPPX,0),"^",3),1,7)'=DT Q
131 I $P(^PS(52.91,PSOTPPX,0),"^",4)'=6 Q
132 N DR,DIE,X1,X2,X,Y,DA,PSOTPPX1,PSOTPPX2,PSOTPPX3,PSOTPPX4,PSOTPPX5,PSOTPPX6,PSOTPPX7,PSOTPPX9
133 S X1=DT,X2=-1 D C^%DTC S PSOTPPX1=X
134 S PSOTPPX9=0
135 F PSOTPPX2=PSOTPPX1:0 S PSOTPPX2=$O(^PS(55,PSOTPPX,"P","A",PSOTPPX2)) Q:'PSOTPPX2 S PSOTPPX3="" F S PSOTPPX3=$O(^PS(55,PSOTPPX,"P","A",PSOTPPX2,PSOTPPX3)) Q:PSOTPPX3="" D
136 .I PSOTPPX'=$P($G(^PSRX(PSOTPPX3,0)),"^",2) Q
137 .I $P($G(^PSRX(PSOTPPX3,"TPB")),"^") Q
138 .I $E($P($G(^PSRX(PSOTPPX3,2)),"^"),1,7)'=DT Q
139 .S PSOTPPX4=$P($G(^PSRX(PSOTPPX3,"STA")),"^") I PSOTPPX4="" Q
140 .I PSOTPPX4'=0,PSOTPPX4'=1,PSOTPPX4'=2,PSOTPPX4'=3,PSOTPPX4'=4,PSOTPPX4'=5,PSOTPPX4'=16 Q
141 .S PSOTPPX5=$P(^PSRX(PSOTPPX3,0),"^",3),PSOTPPX6=$P(^(0),"^",4)
142 .I 'PSOTPPX5!('PSOTPPX6) Q
143 .S PSOTPPX7=$P($G(^PS(53,+PSOTPPX5,0)),"^") S PSOTPPX7=$$UP^XLFSTR(PSOTPPX7) I PSOTPPX7'="NON-VA" Q
144 .I '$P($G(^VA(200,PSOTPPX6,"TPB")),"^")!($P($G(^("TPB")),"^",5)'=0) Q
145 .S $P(^PSRX(PSOTPPX3,"TPB"),"^")=1,PSOTPPX9=1
146 I PSOTPPX9 K DA,DIE,DR S DIE="^PS(52.91,",DA=PSOTPPX,DR="2////"_"@"_";3////"_"@" D ^DIE K DIE,DA,DR
147 Q
148 ;
149SCH ;DBIA to return TPB patients to Scheduling
150 N PSOSCT,PSOSCTD
151 K ^TMP($J,"PSODFN")
152 F PSOSCT=0:0 S PSOSCT=$O(^PS(52.91,PSOSCT)) Q:'PSOSCT I PSOSCT=$P($G(^(PSOSCT,0)),"^") D
153 .S PSOSCTD=$P($G(^PS(52.91,PSOSCT,0)),"^",3)
154 .I 'PSOSCTD!(PSOSCTD>DT) D
155 ..I $P($G(^DPT(PSOSCT,0)),"^")="" Q
156 ..S ^TMP($J,"PSODFN",$P($G(^DPT(PSOSCT,0)),"^"),PSOSCT)=""
157 Q
Note: See TracBrowser for help on using the repository browser.