source: WorldVistAEHR/trunk/r/DRUG_ACCOUNTABILITY-PSA/PSAPROC9.m@ 1736

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

initial load of WorldVistAEHR

File size: 8.6 KB
Line 
1PSAPROC9 ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;8/19/97
2 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**39**; 10/24/97
3 ;This routine processes the line item when the user selects automatic
4 ;processing.
5 ;
6 S (PSACONT,PSADU,PSANEXT)=0
7 I '+$P(PSADATA,"^",6),PSANDC="" D Q:PSAOUT G:PSANEXT NEXT
8 .I +$P($P(PSADATA,"^",5),"~",2) D MANYVSNS^PSAPROC4 D:PSAOUT CONT Q
9 .I PSAVSN="" D Q:PSAOUT G:PSANEXT NEXT
10 ..I +$P($P(PSADATA,"^",26),"~",2) D ^PSAPROC5 D:PSAOUT CONT Q
11 ..I +$P($P(PSADATA,"^",26),"~",3) D SUPDIFF^PSAPROC5 D:PSAOUT CONT
12 I '+$P(PSADATA,"^",6),'+$P(PSADATA,"^",15),PSANDC'="" D ^PSANDF D:PSAOUT CONT Q:PSAOUT
13 I PSANDC'="" D Q:PSAOUT G:PSANEXT NEXT
14 .I +$P($P(PSADATA,"^",4),"~",2) D MANYNDCS^PSAPROC4 D:PSAOUT CONT Q
15 .I $P($P(PSADATA,"^",4),"~",3)'="" D VSNDIFF^PSAPROC5 D:PSAOUT CONT
16 I +$P($P(PSADATA,"^",5),"~",2) D MANYVSNS^PSAPROC4 D:PSAOUT CONT Q:PSAOUT G:PSANEXT NEXT
17 ;VMP OIFO BAY PINES;VGF;PSA*3.0*39
18 I $P($P(PSADATA,"^",5),"~",3)]"" D NDCDIFF^PSAPROC5 D:PSAOUT CONT Q:PSAOUT
19NEXT Q:PSACONT
20 S PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
21 I '+$P(PSADATA,"^",6),'+$P(PSADATA,"^",15),'$D(^XTMP("PSAPV",PSACTRL,"IT",PSALINE,"SUP")) D:'$G(PSAPASS) ASKDRUG^PSANDF D:PSAOUT CONT Q:PSAOUT S PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
22 Q:$G(PSAPASS)
23 I $G(PSASUPP) S PSALINES=PSALINES+1 Q
24 S PSAIEN=$S(+$P(PSADATA,"^",15):+$P(PSADATA,"^",15),1:+$P(PSADATA,"^",6))
25 I PSAIEN S $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",19)=$S($P($G(^PSDRUG(PSAIEN,2)),"^",3)["N":"CS",1:"")
26 I PSAIEN,PSANDC'="" S PSASUB=0 F S PSASUB=$O(^PSDRUG("C",PSANDC,PSAIEN,PSASUB)) Q:'PSASUB I $P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^")=PSANDC Q
27 S $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",7)=$S(+$G(PSASUB):PSASUB,1:"0~1")
28QTY I '+PSADATA,$P(PSADATA,"^",8)="" D QTY^PSAPROC3 D:PSAOUT CONT Q:PSAOUT
29OU I '+$P($P(PSADATA,"^",2),"~",2),'+$P(PSADATA,"^",12) D D:PSAOUT CONT Q:PSAOUT
30 .I PSAIEN,PSASUB,'$P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",5) D GETOU^PSAPROC3 Q
31 .I PSAIEN,'PSASUB D GETOU^PSAPROC3
32DU I PSAIEN,$P($G(^PSDRUG(PSAIEN,660)),"^",8)="" D DU^PSAPROC8 D:PSAOUT CONT Q:PSAOUT
33DUOU ;If drug has synonym & no conv factor set conv factor in 50.
34 I PSAIEN,PSASUB,$D(^PSDRUG(PSAIEN,1,PSASUB,0)),'+$P(^PSDRUG(PSAIEN,1,PSASUB,0),"^",7),'+$P(PSADATA,"^",20) D DUOU^PSAPROC8 D:PSAOUT CONT Q:PSAOUT
35 ;If drug doesn't have synonym & disp units/order unit, store disp units/order unit in XTMP.
36 I PSAIEN,'PSASUB,'+$P(PSADATA,"^",20) D DUOU^PSAPROC3 D:PSAOUT CONT Q:PSAOUT
37PRICE I '+$P(PSADATA,"^",3) D PRICE^PSAPROC3 D:PSAOUT CONT Q:PSAOUT
38NOTCS ;If drug is not a CS & no stock level/reorder level, store in XTMP.
39 S PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
40 I $P(PSADATA,"^",19)'="CS" D Q:PSAOUT
41 .I '+$P(PSAIN,"^",7) D GETLOC D EDITDISP^PSAUTL1,END^PSAPROC D:PSAOUT CONT Q:PSAOUT
42 .I $P(PSADATA,"^",19)'="CS",+$P(PSAIN,"^",7),+$P($G(^PSD(58.8,+$P(PSAIN,"^",7),0)),"^",14) D Q:PSAOUT
43 ..I '+$P($G(^PSD(58.8,+$P(PSAIN,"^",7),1,PSAIEN,0)),"^",3),'+$P(PSADATA,"^",27) S PSALOC=$P(PSAIN,"^",7) D STOCK^PSAPROC8 D:PSAOUT CONT Q:PSAOUT
44 ..I '+$P($G(^PSD(58.8,+$P(PSAIN,"^",7),1,PSAIEN,0)),"^",5),'+$P(PSADATA,"^",21) S PSALOC=$P(PSAIN,"^",7) D REORDER^PSAPROC8 D:PSAOUT CONT
45CS ;If drug is a CS & no stock level/reorder level, store in XTMP.
46 I $P(PSADATA,"^",19)="CS" D Q:PSAOUT
47 .S PSACS=PSACS+1
48 .I '+$P(PSAIN,"^",12) D MASTER D EDITDISP^PSAUTL1,END^PSAPROC D:PSAOUT CONT Q:PSAOUT
49 .I +$P(PSAIN,"^",12),+$P($G(^PSD(58.8,+$P(PSAIN,"^",12),0)),"^",14) D Q:PSAOUT
50 ..I '+$P($G(^PSD(58.8,+$P(PSAIN,"^",12),1,PSAIEN,0)),"^",3),'+$P(PSADATA,"^",27) S PSALOC=$P(PSAIN,"^",12) D STOCK^PSAPROC8 S PSALOC=+$P(PSAIN,"^",7),PSAMV=+$P(PSAIN,"^",12) D:PSAOUT CONT Q:PSAOUT
51 ..I '+$P($G(^PSD(58.8,+$P(PSAIN,"^",12),1,PSAIEN,0)),"^",5),'+$P(PSADATA,"^",21) S PSALOC=$P(PSAIN,"^",12) D REORDER^PSAPROC8 S PSALOC=+$P(PSAIN,"^",7),PSAMV=+$P(PSAIN,"^",12) D:PSAOUT CONT
52 D CHECK^PSANDF D:PSAOUT CONT Q:PSAOUT D SETLINE^PSAPROC3 W !
53 Q
54 ;
55CONT ;Asks if user wants to continue processing invoice.
56 S PSAINV=$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",2)
57 W ! S DIR(0)="Y",DIR("B")="Y",DIR("A")="Do you want to continue processing invoice# "_PSAINV,DIR("?")="Enter YES to process the next line item.",DIR("?")="Enter NO to stop processing the invoice.",DIR("??")="^D CONTYN^PSAPROC9"
58 D ^DIR K DIR S PSACONT=Y Q:$G(DIRUT)!('Y)
59 S PSAOUT=0
60 Q
61MASTER ;Assigns invoice to Master Vault
62 S PSAINV=$P($G(^XTMP("PSAPV",PSACTRL,"IN")),"^",2)
63 S (PSAMVN,PSAMV)=0 F S PSAMV=+$O(^PSD(58.8,"ADISP","M",PSAMV)) Q:'PSAMV D
64 .Q:'$D(^PSD(58.8,PSAMV,0))!($P($G(^PSD(58.8,PSAMV,0)),"^")="")
65 .I +$G(^PSD(58.8,PSAMV,"I")),+^PSD(58.8,PSAMV,"I")'>DT Q
66 .S PSAMVN=PSAMVN+1,PSAONEMV=PSAMV,PSAMV($P(^PSD(58.8,PSAMV,0),"^"),PSAMV)=""
67 I 'PSAMVN W !!,"No master vaults are set up. You must set up a master vault then",!,"select the Process Uploaded Prime Vendor Invoices Data option." S PSAOUT=1 Q
68 I PSAMVN=1 D Q
69 .S PSAMV=PSAONEMV
70 .W @IOF,!?22,"<<< ASSIGN A MASTER VAULT SCREEN >>>"
71 .W !!,"Controlled substances on the invoice has been",!,"automatically assigned to the Master Vault."
72 .W !!,$P(^PSD(58.8,PSAMV,0),"^"),!,PSASLN
73 .W !,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(+PSAIN)
74 .S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)=PSAMV,PSAIN=^("IN")
75 .D END^PSAPROC
76 I PSAMVN>1 D DISPMV W !,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(+PSAIN) D SELMV
77 Q
78 ;
79DISPMV ;Displays active master vaults
80 W @IOF,!?22,"<<< ASSIGN A MASTER VAULT SCREEN >>>",!,PSASLN
81 S PSA=0,PSAMVA="" F S PSAMVA=$O(PSAMV(PSAMVA)) Q:PSAMVA="" D
82 .S PSAMVIEN=0 F S PSAMVIEN=$O(PSAMV(PSAMVA,PSAMVIEN)) Q:'PSAMVIEN D
83 ..S PSA=PSA+1,PSAVAULT(PSA,PSAMVA,PSAMVIEN)=""
84 ..W !,$J(PSA,2)_".",?4,PSAMVA
85 W !
86 Q
87 ;
88SELMV ;Select displayed master vaults
89 W ! S DIR(0)="NO^1:"_PSA,DIR("A")="Select Master Vault",DIR("?")="Select the Master Vault that received the invoice's drugs"
90 S DIR("??")="^D MV^PSAPROC" D ^DIR K DIR Q:Y="" I $G(DIRUT) S PSAOUT=1 Q
91 S PSASEL1=Y
92 S PSAMVA=$O(PSAVAULT(PSASEL1,"")) Q:PSAMVA="" S PSAMVIEN=+$O(PSAVAULT(PSASEL1,PSAMVA,0)) Q:'PSAMVIEN S PSAMV=PSAMVIEN,$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)=PSAMV,PSAIN=^("IN")
93 Q
94 ;
95GETLOC ;Gets pharmacy locations
96 S PSAINV=$P($G(^XTMP("PSAPV",PSACTRL,"IN")),"^",2)
97 S (PSALOC,PSANUM)=0 F S PSALOC=+$O(^PSD(58.8,"ADISP","P",PSALOC)) Q:'PSALOC D
98 .Q:'$D(^PSD(58.8,PSALOC,0))!($P($G(^PSD(58.8,PSALOC,0)),"^")="")
99 .I +$G(^PSD(58.8,PSALOC,"I")),+^PSD(58.8,PSALOC,"I")'>DT Q
100 .S PSANUM=PSANUM+1,PSAONE=PSALOC,PSAISIT=+$P(^PSD(58.8,PSALOC,0),"^",3),PSAOSIT=+$P(^(0),"^",10)
101 .D SITES^PSAUTL1 S PSALOCA($P(^PSD(58.8,PSALOC,0),"^")_PSACOMB,PSALOC)=PSAISIT_"^"_PSAOSIT
102 G:'PSANUM NONE G:PSANUM=1 ONE G:PSANUM>1 MANY
103 ;
104NONE ;No DA pharmacy locations
105 W !!,"There are no Drug Accountability pharmacy locations.",!!,"Use the Set Up/Edit a Pharmacy Location option on Pharmacy Location menu"
106 W !,"to setup one or more pharmacy locations. Then select the Process Uploaded",!,"Prime Vendor Invoice Data option to process the invoices."
107 Q
108 ;
109ONE ;Only one location
110 S PSACNT=0,PSALOC=PSAONE,PSALOCN=$O(PSALOCA(""))
111 W @IOF,!?19,"<<< ASSIGN A PHARMACY LOCATION SCREEN >>>"
112 W !!,"The non-controlled substance items on the invoice have",!,"been automatically assigned to the Pharmacy Location.",!
113 W:$L(PSALOCN)>76 !,$P(PSALOCN,"(IP)",1)_"(IP)",!?17,$P(PSALOCN,"(IP)",2) W:$L(PSALOCN)<77 PSALOCN W !,PSASLN
114 W !!,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(+PSAIN)
115 S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",7)=PSALOC,PSAIN=^("IN")
116 Q
117 ;
118MANY ;If more than one pharmacy location, display invoices.
119 D DISPLOC W !,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(+PSAIN) D SELLOC
120 Q
121 ;
122DISPLOC ;Displays the active pharmacy locations.
123 W @IOF,!?19,"<<< ASSIGN A PHARMACY LOCATION SCREEN >>>",!,PSASLN,!
124 S PSACNT=0,PSALOCN="" F S PSALOCN=$O(PSALOCA(PSALOCN)) Q:PSALOCN="" D
125 .S PSALOC=0 F S PSALOC=$O(PSALOCA(PSALOCN,PSALOC)) Q:'PSALOC D
126 ..S PSACNT=PSACNT+1,PSAMENU(PSACNT,PSALOCN,PSALOC)=PSALOC
127 ..W !,$J(PSACNT,2)_"." W:$L(PSALOCN)>72 ?4,$P(PSALOCN,"(IP)",1)_"(IP)",!?21,$P(PSALOCN,"(IP)",2) W:$L(PSALOCN)<73 ?4,PSALOCN
128 W !
129 Q
130 ;
131SELLOC ;Select the Pharmacy Location to be assigned to the order.
132 W ! K DIR S DIR(0)="NO^1:"_PSACNT,DIR("A")="Pharmacy Location",DIR("?")="Select the pharmacy location that received the invoice's drugs"
133 S DIR("??")="^D LOCHELP^PSAVER5" D ^DIR K DIR Q:Y="" I $G(DIRUT) S PSAOUT=1 Q
134 S PSASEL1=Y
135 S PSALOCN=$O(PSAMENU(PSASEL1,"")) Q:PSALOCN="" S PSALOC=$O(PSAMENU(PSASEL1,PSALOCN,0)) Q:'PSALOC S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",7)=PSALOC,PSAIN=^("IN")
136 Q
137 ;
138CONTYN ;Extended help for 'Do you want to continue processing invoice# 99'
139 W !?5,"Enter YES to continue processing the current invoice and line item.",!?5,"Enter NO to discontinue processing the current invoice and exit the option."
140 Q
Note: See TracBrowser for help on using the repository browser.