1 | PSOAFIN ;VFA/HMS autofinish rx's from cprs ;4/21/07 19:10
|
---|
2 | ;;7.0;OUTPATIENT PHARMACY;**208**;DEC 1997;Build 39
|
---|
3 | ; Copyright (C) 2007 WorldVistA
|
---|
4 | ;
|
---|
5 | ; This program is free software; you can redistribute it and/or modify
|
---|
6 | ; it under the terms of the GNU General Public License as published by
|
---|
7 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
8 | ; (at your option) any later version.
|
---|
9 | ;
|
---|
10 | ; This program is distributed in the hope that it will be useful,
|
---|
11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | ; GNU General Public License for more details.
|
---|
14 | ;
|
---|
15 | ; You should have received a copy of the GNU General Public License
|
---|
16 | ; along with this program; if not, write to the Free Software
|
---|
17 | ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
18 | ;
|
---|
19 | ; Please note this routine is the gateway to modified routines that autofinish pending rxs entered by a provider. The modified routines allow rxs to be finished automatically & properly update File#100 and File#52.
|
---|
20 | ; The routines do not autocheck orders, check for duplicates, concatenate comments to sigs etc. All of the pharmacist checks will be done by the dispensing pharmacist.
|
---|
21 | ; $G(PSOAFYN) is tested at beginning of line to determine if the original code will run or if code modified to do AutoFinish,Rx will run
|
---|
22 | EN I '$D(^PS(52.41,"B",+ORDERID)) Q ;Check for pending order
|
---|
23 | N ZTRTN,ZTDESC,ZTDTH,ZTSAVE,ZTSK
|
---|
24 | S ZTRTN="EN1^PSOAFIN",ZTDESC="Autofinish,Rx",ZTDTH=$H,ZTDTH=$S(($P(ZTDTH,",",2)+10)\86400:(1+ZTDTH)_","_((($P(ZTDTH,",",2)+10)#86400)/100000),1:(+ZTDTH)_","_($P(ZTDTH,",",2)+10))
|
---|
25 | S ZTSAVE("ORL")="",ZTSAVE("ORVP")="",ZTSAVE("IO*")="",ZTSAVE("VALMWD")="",ZTSAVE("ORL")="",ZTSAVE("ORDERID")="" D ^%ZTLOAD
|
---|
26 | Q ;Quits back to ORWDX
|
---|
27 | ;
|
---|
28 | EN1 ;Autofinish Task Begins Here
|
---|
29 | S PSOSITE=$G(^SC(+ORL,"AFRXSITE")) ;+ORL is hospital location from ORWDX
|
---|
30 | Q:PSOSITE="" ;Quits with no autofinish if File#44 does not point to File#59
|
---|
31 | I $P($G(^PS(59,PSOSITE,"RXFIN")),"^",1)'="Y" Q ;Quits if Autofinish not turned on in File#59 Field#459001
|
---|
32 | ;Check patient eligibility
|
---|
33 | S VFAELD="Y"
|
---|
34 | I $D(^PS(59,PSOSITE,"RXFINEL",1)) S VFAELD="N",DFN=+ORVP D ELIG^VADPT D
|
---|
35 | .S VFAEL=0
|
---|
36 | .F L=1:1 S VFAEL=$O(^PS(59,PSOSITE,"RXFINEL",VFAEL)) Q:VFAEL=""!(VFAEL="B")!(VFAELD="Y") D
|
---|
37 | ..S VFAELL=$P(^PS(59,PSOSITE,"RXFINEL",VFAEL,0),"^",1)
|
---|
38 | ..I VFAELL=+VAEL(1) S VFAELD="Y"
|
---|
39 | Q:VFAELD="N"
|
---|
40 | ;Check Date Verify Code Last Changed and check Verify Code never expires.
|
---|
41 | S PSOAFYN="Y" ;Sets flag if Autofinish,Rx is turned on & is used throughout the routines
|
---|
42 | S DIC="^VA(200,",DIC(0)="QEZ",X="AUTOFINISH,RX"
|
---|
43 | D ^DIC K DIC
|
---|
44 | Q:+Y=-1 ;Quits if AUTOFINISH,RX not a user
|
---|
45 | S DA=+Y
|
---|
46 | D DUZ^XUP(DA) ;Sets DUZ for AUTOFINISH,RX
|
---|
47 | K PSOAFDON ;Makes sure flag for quitting patient loop through File#52.41 is null
|
---|
48 | S PSOAFDFN=+ORVP ;From ORWDX CPRS Call is DFN of patient auto finishing rxs for
|
---|
49 | S PSOAFPAT=$P($G(^PS(55,PSOAFDFN,"PS")),"^") ;Sets patient status if it exists
|
---|
50 | I $G(PSOAFPAT)="" D
|
---|
51 | .I $P($G(^PS(59,PSOSITE,"RXFIN")),"^",2)'="" D
|
---|
52 | ..S ^PS(55,PSOAFDFN,"PS")=$P(^PS(59,PSOSITE,"RXFIN"),"^",2)
|
---|
53 | ..S PSOAFPAT=$P(^PS(59,PSOSITE,"RXFIN"),"^",2)
|
---|
54 | I $G(PSOAFPAT)="" D NOPATS ;Prints message if no patient status
|
---|
55 | S PSORX("PATIENT STATUS")=PSOAFPAT ;HMS 2007_03_11
|
---|
56 | S PSOAFPNM=$P(^DPT(PSOAFDFN,0),"^",1)
|
---|
57 | S (PSODFN,PAT)=PSOAFDFN,PSOFINY=PSOAFDFN_"^"_PSOAFPNM
|
---|
58 | D ^PSOORFIN ;Begins execution of Rx Finishing routines
|
---|
59 | K PSOAFDFN,PSOAFYN,PSOAFDON,PSOAFDUZ,PSOAFPAT,PAT,PSODFN,PSOFINY,PSOSITE
|
---|
60 | Q ;Autofinish Task Quits Here
|
---|
61 | ;
|
---|
62 | ;
|
---|
63 | ;
|
---|
64 | NOPATS ;Quit message prints instead of prescription if no patient status
|
---|
65 | ;Checks for nw orders in File#52.41
|
---|
66 | ;I $G(REA)'="" Q ;Quits if not signing a new rx
|
---|
67 | S PSOAFORB=+ORDERID-1,PSOAFORB=$O(^PS(52.41,"B",PSOAFORB)),PSOAFOB1="",PSOAFOB1=$O(^PS(52.41,"B",PSOAFORB,PSOAFOB1)),PSOAFRXS=$P(^PS(52.41,PSOAFOB1,0),"^",3)
|
---|
68 | I PSOAFRXS'="NW" K PSOAFORB,PSOAFOB1,PSOAFRXS Q ;Quits if no new pending rxs in File#52.41
|
---|
69 | K PSOAFORB,PSOAFOB1,PSOAFRXS
|
---|
70 | I $G(PSOAFYN)="Y" S PSOLAP=$G(^SC(+ORL,"AFRXCLINPRNT")) ;vfah sets printer as defined in File#44
|
---|
71 | I $G(PSOAFYN)="Y" I PSOLAP="" S DIRUT="^" G:$D(DIRUT)!($D(DUOUT)) EX ;vfah If DIRUT set to "^" will bypass label printing, queueing etc if no printer defined in File#44
|
---|
72 | I $G(PSOAFYN)="Y" S PSOLAP=$P(^%ZIS(1,PSOLAP,0),"^",1) ;vhah sets PSOLAP to literal of printer name
|
---|
73 | S PSOAFPNM=$P(^DPT(PSOAFDFN,0),"^",1)
|
---|
74 | S PSOAFPNM=$P(^DPT(PSOAFDFN,0),"^",1)
|
---|
75 | QLBL ;Queues no patient status notice
|
---|
76 | D ^%ZISC
|
---|
77 | S ZTRTN="PLBL^PSOAFIN",ZTIO=$G(PSOLAP),ZTDESC="Autofinish,Rx No Patient Status Message",ZTDTH=$H ;Sets Taskman variables
|
---|
78 | Q:PSOLAP=""
|
---|
79 | S ZTSAVE("*")=""
|
---|
80 | D ^%ZTLOAD
|
---|
81 | H 1
|
---|
82 | D ^%ZISC
|
---|
83 | K PSOAFDFN,PSOAFPNM
|
---|
84 | Q
|
---|
85 | ;
|
---|
86 | PLBL ;Prints no patient status notice
|
---|
87 | W !,"CAN NOT AUTO-FINISH or MANUALLY FINISH RX(S)"
|
---|
88 | W !!,"FOR PATIENT: ",PSOAFPNM_" "_$E($P($G(^DPT(PSOAFDFN,0)),"^",9),4,5)_"-"_$E($P($G(^DPT(PSOAFDFN,0)),"^",9),6,9)
|
---|
89 | W !!,"THERE IS NO PATIENT STATUS SET FOR THIS PATIENT."
|
---|
90 | W !!,"PLEASE ENTER A PATIENT STATUS FOR THIS PATIENT"
|
---|
91 | W !,"AND THEN SIGN RXS IN CPRS TO AUTOFINISH RXS"
|
---|
92 | W !!,"THANK YOU"
|
---|
93 | W !,"AUTOFINISH,RX"
|
---|
94 | W !,$$FMTE^XLFDT($$NOW^XLFDT())
|
---|
95 | D ^%ZISC
|
---|
96 | EX K PSOAFDFN,PSOAFYN,PSOAFDON,PSOAFDUZ,PSOAFPNM,PSOAFPAT,PAT,PSODFN,PSOFINY,PSOSITE
|
---|
97 | Q
|
---|
98 | ;
|
---|
99 | DISPD ;Selects dispense drug if not selected in CPRS
|
---|
100 | S PSI=0
|
---|
101 | F PSI=0:0 S PSI=$O(^PSDRUG("ASP",PSODRUG("OI"),PSI)) Q:'PSI I $S('$D(^PSDRUG(PSI,"I")):1,'^("I"):1,DT'>^("I"):1,1:0),$S($P($G(^PSDRUG(PSI,2)),"^",3)'["O":0,1:1) D Q:PSI>0
|
---|
102 | .S $P(OR0,"^",9)=PSI,$P(^PS(52.41,ORD,0),"^",9)=PSI
|
---|
103 | S VFASDD="Y"
|
---|
104 | Q
|
---|