source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOAFIN.m@ 619

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1PSOAFIN ;VFA/HMS autofinish rx's from cprs ;2:33 PM 11 Nov 2008
2 ;;7.0;OUTPATIENT PHARMACY;**208,250003**;DEC 1997;Build 41
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
22EN I '$D(^PS(52.41,"B",+ORDERID)) Q ;Check for pending order
23 N ZTRTN,ZTDESC,ZTDTH,ZTSAVE,ZTSK,ZTIO
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("VALMWD")=""
26 S ZTSAVE("ORL")="",ZTSAVE("ORDERID")=""
27 S ZTIO="NULL" ;WVEHR - 250003
28 D ^%ZTLOAD
29 Q ;Quits back to ORWDX
30 ;
31EN1 ;Autofinish Task Begins Here
32 ;D ^%ZTER ; For testing *ONLY*
33 ;S IOP="NULL" D ^%ZIS U IO
34 S PSOSITE=$G(^SC(+ORL,"AFRXSITE")) ;+ORL is hospital location from ORWDX
35 Q:PSOSITE="" ;Quits with no autofinish if File#44 does not point to File#59
36 I $P($G(^PS(59,PSOSITE,"RXFIN")),"^",1)'="Y" Q ;Quits if Autofinish not turned on in File#59 Field#459001
37 ;Check patient eligibility
38 S VFAELD="Y"
39 I $D(^PS(59,PSOSITE,"RXFINEL",1)) S VFAELD="N",DFN=+ORVP D ELIG^VADPT D
40 .S VFAEL=0
41 .F L=1:1 S VFAEL=$O(^PS(59,PSOSITE,"RXFINEL",VFAEL)) Q:VFAEL=""!(VFAEL="B")!(VFAELD="Y") D
42 ..S VFAELL=$P(^PS(59,PSOSITE,"RXFINEL",VFAEL,0),"^",1)
43 ..I VFAELL=+VAEL(1) S VFAELD="Y"
44 Q:VFAELD="N"
45 ;Check Date Verify Code Last Changed and check Verify Code never expires.
46 S PSOAFYN="Y" ;Sets flag if Autofinish,Rx is turned on & is used throughout the routines
47 S DIC="^VA(200,",DIC(0)="QEZ",X="AUTOFINISH,RX"
48 D ^DIC K DIC
49 Q:+Y=-1 ;Quits if AUTOFINISH,RX not a user
50 S DA=+Y
51 D DUZ^XUP(DA) ;Sets DUZ for AUTOFINISH,RX
52 K PSOAFDON ;Makes sure flag for quitting patient loop through File#52.41 is null
53 S PSOAFDFN=+ORVP ;From ORWDX CPRS Call is DFN of patient auto finishing rxs for
54 S PSOAFPAT=$P($G(^PS(55,PSOAFDFN,"PS")),"^") ;Sets patient status if it exists
55 I $G(PSOAFPAT)="" D
56 .I $P($G(^PS(59,PSOSITE,"RXFIN")),"^",2)'="" D
57 ..S ^PS(55,PSOAFDFN,"PS")=$P(^PS(59,PSOSITE,"RXFIN"),"^",2)
58 ..S PSOAFPAT=$P(^PS(59,PSOSITE,"RXFIN"),"^",2)
59 I $G(PSOAFPAT)="" D NOPATS ;Prints message if no patient status
60 S PSORX("PATIENT STATUS")=PSOAFPAT ;HMS 2007_03_11
61 S PSOAFPNM=$P(^DPT(PSOAFDFN,0),"^",1)
62 S (PSODFN,PAT)=PSOAFDFN,PSOFINY=PSOAFDFN_"^"_PSOAFPNM
63 D ^PSOORFIN ;Begins execution of Rx Finishing routines
64 K PSOAFDFN,PSOAFYN,PSOAFDON,PSOAFDUZ,PSOAFPAT,PAT,PSODFN,PSOFINY,PSOSITE
65 Q ;Autofinish Task Quits Here
66 ;
67 ;
68 ;
69NOPATS ;Quit message prints instead of prescription if no patient status
70 ;Checks for nw orders in File#52.41
71 ;I $G(REA)'="" Q ;Quits if not signing a new rx
72 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)
73 I PSOAFRXS'="NW" K PSOAFORB,PSOAFOB1,PSOAFRXS Q ;Quits if no new pending rxs in File#52.41
74 K PSOAFORB,PSOAFOB1,PSOAFRXS
75 I $G(PSOAFYN)="Y" S PSOLAP=$G(^SC(+ORL,"AFRXCLINPRNT")) ;vfah sets printer as defined in File#44
76 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
77 I $G(PSOAFYN)="Y" S PSOLAP=$P(^%ZIS(1,PSOLAP,0),"^",1) ;vhah sets PSOLAP to literal of printer name
78 S PSOAFPNM=$P(^DPT(PSOAFDFN,0),"^",1)
79 S PSOAFPNM=$P(^DPT(PSOAFDFN,0),"^",1)
80QLBL ;Queues no patient status notice
81 D ^%ZISC
82 S ZTRTN="PLBL^PSOAFIN",ZTIO=$G(PSOLAP),ZTDESC="Autofinish,Rx No Patient Status Message",ZTDTH=$H ;Sets Taskman variables
83 Q:PSOLAP=""
84 S ZTSAVE("*")=""
85 D ^%ZTLOAD
86 H 1
87 D ^%ZISC
88 K PSOAFDFN,PSOAFPNM
89 Q
90 ;
91PLBL ;Prints no patient status notice
92 W !,"CAN NOT AUTO-FINISH or MANUALLY FINISH RX(S)"
93 W !!,"FOR PATIENT: ",PSOAFPNM_" "_$E($P($G(^DPT(PSOAFDFN,0)),"^",9),4,5)_"-"_$E($P($G(^DPT(PSOAFDFN,0)),"^",9),6,9)
94 W !!,"THERE IS NO PATIENT STATUS SET FOR THIS PATIENT."
95 W !!,"PLEASE ENTER A PATIENT STATUS FOR THIS PATIENT"
96 W !,"AND THEN SIGN RXS IN CPRS TO AUTOFINISH RXS"
97 W !!,"THANK YOU"
98 W !,"AUTOFINISH,RX"
99 W !,$$FMTE^XLFDT($$NOW^XLFDT())
100 D ^%ZISC
101EX K PSOAFDFN,PSOAFYN,PSOAFDON,PSOAFDUZ,PSOAFPNM,PSOAFPAT,PAT,PSODFN,PSOFINY,PSOSITE
102 Q
103 ;
104DISPD ;Selects dispense drug if not selected in CPRS
105 S PSI=0
106 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
107 .S $P(OR0,"^",9)=PSI,$P(^PS(52.41,ORD,0),"^",9)=PSI
108 S VFASDD="Y"
109 Q
Note: See TracBrowser for help on using the repository browser.