source: WorldVistAEHR/trunk/r/DRUG_ACCOUNTABILITY-PSA/PSAVER1.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: 8.0 KB
Line 
1PSAVER1 ;BIR/JMB-Verify Invoices - CONT'D ;7/23/97
2 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**33,60,65**; 10/24/97;Build 2
3 ;This routine allows the user to edit processed invoices by selecting
4 ;the invoice's line item number. If there are no errors after editing
5 ;the line item is verified.
6 ;
7 ;References to global ^DIC(51.5 are covered by IA #1931
8 ;References to global ^PSDRUG( are covered by IA #2095
9 ;
10EDIT W @IOF,!?18,"<<< EDIT INVOICES TO BE VERIFIED SCREEN >>>",!!?2,"Choose the invoices from the list you want to edit.",!,PSASLN
11 S (PSA,PSACNT,PSASTOP)=0,PSATMP="" F S PSA=+$O(PSAEDIT(PSA)) Q:'PSA D Q:PSASTOP
12 .I $Y+5>IOSL D HEADER Q:PSASTOP
13 .S PSAIEN=$P(PSAEDIT(PSA),"^"),PSAIEN1=$P(PSAEDIT(PSA),"^",2),PSAORD=$P(^PSD(58.811,PSAIEN,0),"^")
14 .S PSAINV=$P(^PSD(58.811,PSAIEN,1,PSAIEN1,0),"^"),PSAINVDT=+$P(^(0),"^",2),PSACNT=PSACNT+1
15 .W !?2,PSA_".",?6,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(PSAINVDT)
16 K PSASTOP W !,PSASLN
17 S DIR(0)="LO^1:"_PSACNT,DIR("A")="Select invoices to edit",DIR("?",1)="Enter the number to the left of the invoice",DIR("?")="data to be verified or a range of numbers.",DIR("??")="^D SELHELP^PSAVER"
18 W ! D ^DIR K DIR Q:$G(DIRUT)
19 S PSASEL=Y
20 ;
21SEL ;Select line items to be edit
22 K PSAVBKG S PSATMP=""
23 F PSAPC=1:1 S PSA=$P(PSASEL,",",PSAPC) Q:'PSA D CORR Q:PSAOUT
24 I $O(PSAVBKG(0)) D
25 .K ZTSAVE S ZTDESC="Drug Acct. - Verify Prime Vendor Invoices",ZTIO="",ZTDTH=$H,ZTRTN="^PSAVER6",ZTSAVE("PSAVBKG(")="" D ^%ZTLOAD
26 Q
27 ;
28HEADER ;Header with screen hold
29 S PSASS=21-$Y F PSAKK=1:1:PSASS W !
30 S DIR(0)="E" D ^DIR K DIR I $G(DIRUT) S PSASTOP=1 Q
31 W @IOF,!?18,"<<< EDIT INVOICES TO BE VERIFIED SCREEN >>>",!!,PSASLN
32 Q
33 ;
34CORR N PSASEL1 S PSASEL1=PSASEL N PSASEL ;;<*65 RJS
35 S PSAIEN=$P(PSAEDIT(PSA),"^"),PSAIEN1=$P(PSAEDIT(PSA),"^",2),PSASEL=PSA ;;*65 RJS>
36 S PSAMSG="" D VERLOCK^PSAVER4 ; <== PSA*3*60 (RJS-VMP)
37 I $L(PSAMSG) D Q
38 .D HDR W !,?5,PSAMSG,! S DIR(0)="E" D ^DIR K DIR S PSASEL=PSASEL1 K PSALOCK(PSA),PSASEL1
39 S PSAIN=^PSD(58.811,PSAIEN,1,PSAIEN1,0),PSAINV=$P(^(0),"^"),PSAINVDT=$P(^(0),"^",2),PSAORD=$P(^PSD(58.811,PSAIEN,0),"^")
40 D HDR,RECD^PSAVER2 D:PSAOUT
41 .I PSAOUT D VERUNLCK^PSAVER4 W !,"** The invoice's status has not been changed to Verified!"
42 I $G(PSAOUT)!$G(DUOUT) S PSAOUT=0,PSASEL=PSASEL1 K PSALOCK(PSA),PSASEL1 Q
43 S PSALOC=+$P(PSAIN,"^",5),PSAMV=+$P(PSAIN,"^",12)
44 I PSALOC!($P(PSAIN,"^",8)="S")!($P(PSAIN,"^",8)="N") D Q:PSAOUT
45 .D SITES^PSAUTL1 S PSALOCN=$S($G(PSALOC)'>0:"UNKNOWN",1:$P(^PSD(58.8,PSALOC,0),"^"))_PSACOMB
46 .W:$L(PSALOCN)>76 !!,$P(PSALOCN,"(IP)",1)_"(IP)",!?17,$P(PSALOCN,"(IP)",2) W:$L(PSALOCN)<77 !!,PSALOCN
47 .S DR=4 D PHARM^PSAVER2
48 I PSAMV!($P(PSAIN,"^",8)="S")!($P(PSAIN,"^",8)="A") W !!,$P($G(^PSD(58.8,PSAMV,0)),"^") S DR=13 D PHARM^PSAVER2
49 I X="" D VERUNLCK^PSAVER4 W !,"** The invoice's status has not been changed to Verified!" S PSAOUT=0,PSASEL=PSASEL1 K PSALOCK(PSA),PSASEL1 Q
50 ;
51LINES F W ! S DIC="^PSD(58.811,"_PSAIEN_",1,"_PSAIEN1_",1,",DA(2)=PSAIEN,DA(1)=PSAIEN1,DIC(0)="QAEMZ",DIC("A")="Select Line#: " D ^DIC K DIC D Q:PSAOUT
52 .I $G(DTOUT)!($G(DUOUT))!(Y<1) S PSAOUT=1 Q
53 .S PSALINE=+Y,PSALINEN=$P(Y,"^",2)
54 .I '$D(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,0)) W !,"Invalid line number." Q
55 .S PSADATA=^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,0),PSASUP=0
56 .S PSANDC=$P(PSADATA,"^",11),PSAVSN=$P(PSADATA,"^",12),PSALOC=$S(+$P(PSADATA,"^",10):+$P(PSAIN,"^",12),1:+$P(PSAIN,"^",5))
57VIEW .D HDR,VERDISP^PSAUTL4 W PSASLN,!
58 .W "1. Drug",!,"2. Quantity Received",!,"3. Order Unit",!,"4. Dispense Units per Order Unit",! S PSACHO=4
59 .I $P($G(^PSD(58.8,PSALOC,0)),"^",14) W "5. Stock Level",!,"6. Reorder Level",! S PSACHO=6
60 .S DIR(0)="LO^1:"_PSACHO,DIR("A")="Edit fields",DIR("?")="Enter the number(s) of the data to be edited" S DIR("??")="^D DDQOR^PSAVER3"
61 .D ^DIR K DIR I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q
62 .Q:Y="" S PSAFLDS=Y,PSASET=0 D HDR,VERDISP^PSAUTL4 W PSASLN
63FIELDS .F PSAPCF=1:1 S PSAFLD=$P(PSAFLDS,",",PSAPCF) Q:'PSAFLD!(PSAOUT) D
64 ..I PSAFLD=1 D ASKDRUG^PSAVER2 Q
65 ..I PSAFLD=2 D QTY^PSAVER2 Q
66 ..I PSAFLD=3 D OU^PSAVER2 Q
67 ..I PSAFLD=4,'PSASET S PSA50IEN=PSADRG D DUOU^PSAVER2 Q
68 ..I PSAFLD=5 D STOCK^PSAVER2 Q
69 ..I PSAFLD=6 D REORDER^PSAVER2
70 ;<== PSA*3*60 (RJS-VMP)
71 ;Determines if the invoice's status should be changed to verified. If
72 ;so, the status is changed and the new drugs to the location is listed.
73 W ! S DIR(0)="Y",DIR("A")="Do you want to change the invoice's status to Verified",DIR("?",1)="Enter YES to change the invoice's status to Verified.",DIR("?")="Enter NO to keep the invoice's status as Processed."
74 S DIR("??")="^D CHGYN^PSAVER1" D ^DIR K DIR ;D:'Y VERUNLCK^PSAVER4
75 I $G(DIRUT)!('Y) D VERUNLCK^PSAVER4 W !,"** The invoice's status has not been changed to Verified!" S (PSAOUT,PSACHG)=0,PSASEL=PSASEL1 K PSALOCK(PSA),PSASEL1 Q
76 S PSACHG=Y,PSAVBKG(PSAIEN,PSAIEN1)=""
77 ;==> PSA*3*60 (RJS-VMP)
78 ;Looks to see if all line items are processed.
79PROCESS S (PSACS,PSAERR,PSALINE,PSALINES,PSALNCNT,PSALNSU,PSAOUT,PSASUP)=0
80 S PSAIN=$G(^PSD(58.811,PSAIEN,1,PSAIEN1,0)),PSAORD=$P($G(^PSD(58.811,PSAIEN,0)),"^")
81 F S PSALINE=$O(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE)) Q:'PSALINE!(PSAOUT) D
82 .S PSADATA=^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,0),PSALNERR=0,PSALNCNT=PSALNCNT+1
83 .D SETLINE^PSAVER3 I PSAOUT D VERUNLCK^PSAVER4 W !,"** The invoice's status has not been changed to Verified!" S (PSAOUT,PSACHG)=0,PSASEL=PSASEL1 K PSALOCK(PSA),PSASEL1 Q
84 .S:'+$G(PSALNERR) PSALINES=PSALINES+1 S PSADATA=^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,0)
85 .S:+$P(PSADATA,"^",10) PSACS=PSACS+1
86 ;
87CHECK I PSALNCNT'=PSALINES D Q
88 .K PSAHOLD(PSALOC,PSAIEN,PSAIEN1) W !!,"** The invoice has not been placed in a Verified status!"
89 .D END^PSAPROC D:+$G(PSAERR) PRINT^PSAVER3
90 .D VERUNLCK^PSAVER4 S PSASEL=PSASEL1 K PSALOCK(PSA),PSASEL1,PSAVBKG(PSAIEN,PSAIEN1) Q ;;<*65 RJS>
91 I +PSALNCNT,PSALNCNT=PSACS D
92 .S $P(^PSD(58.811,PSAIEN,1,PSAIEN1,0),"^",8)="A" W !,"All drugs on the invoice are marked as a controlled substance."
93 .D:'+$P($G(^PSD(58.811,PSAIEN,1,PSAIEN1,0)),"^",12) MASTER^PSAVER5
94 I PSACS,PSALNCNT'=PSACS S $P(^PSD(58.811,PSAIEN,1,PSAIEN1,0),"^",8)="S" D:'$P($G(^PSD(58.811,PSAIEN,1,PSAIEN1,0)),"^",5) GETLOC^PSAVER5
95 I 'PSACS S $P(^PSD(58.811,PSAIEN,1,PSAIEN1,0),"^",8)="N" D:'$P($G(^PSD(58.811,PSAIEN,1,PSAIEN1,0)),"^",5) GETLOC^PSAVER5
96 I +PSALNCNT,PSALNCNT=PSALINES D Q
97 .D CHG
98 .I PSALNCNT=PSASUP S $P(^PSD(58.811,PSAIEN,1,PSAIEN1,0),"^",13)=1 Q
99 .S $P(^PSD(58.811,PSAIEN,1,PSAIEN1,0),"^",13)=0
100 D END^PSAPROC D:+$G(PSAERR) PRINT^PSAVER3
101 Q
102 ;<== PSA*3*60 (RJS-VMP)
103CHG D STATUS^PSAVER3,NEWDRUG
104 W !!,"The invoice status has been changed to Verified!"
105 D END^PSAPROC
106 Q
107 ;
108NEWDRUG ;If this invoice will add new drugs to location/vault, store in an
109 ;array the location/vault and drug name to be printed later.
110 K PSALND,PSALN0,PSALNP,PSALNV
111 S PSALINE=0,PSAPHARM=+$P($G(^PSD(58.811,PSAIEN,1,PSAIEN1,0)),"^",5),PSAMV=$P($G(^(0)),"^",12)
112 Q:'PSALOC
113 F S PSALINE=$O(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE)) Q:'PSALINE D
114 .S PSALN0=+$P($G(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,0)),"^",2),PSALOC=$S($P($G(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,0)),"^",10):PSAMV,1:PSAPHARM)
115 .I $O(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,1,"D",0)) D
116 ..S PSADJ=$O(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,1,"D",0))
117 ..Q:'$D(^PSD(58.811,PSAIEN,1,PSAIEN1,1,PSALINE,1,PSADJ,0))
118 ..S PSALNP=+$P(PSADJ,"^",2),PSALNV=+$P(PSADJ,"^",6)
119 .S PSADD=$S($G(PSALNV):PSALNV,$G(PSALNP):PSALNP,PSALN0:PSALN0,1:0)
120 .I PSADD,'$D(^PSD(58.8,PSALOC,1,PSADD,0)) S PSANEWD(PSALOC,$S($P($G(^PSDRUG(PSADD,0)),"^")'="":$P($G(^PSDRUG(PSADD,0)),"^"),1:"UNKNOWN"))=PSADD
121 Q
122 ;
123HDR ;Header for screen that displays invoice data to be edited.
124 W @IOF,!?18,"<<< EDIT INVOICES TO BE VERIFIED SCREEN >>>"
125 W !!,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(PSAINVDT),!,PSASLN,!
126 Q
127 ;
128CHGYN ;Extended help for 'Do you want to change the invoice's status to Verified'
129 W !?5,"Enter YES if the invoice is completely correct. You will not be able",!?5,"to edit it again."
130 W !!?5,"Enter NO if you need to edit the invoice again. You can edit it again",!?5,"by selecting the Verify Orders option."
131 Q
Note: See TracBrowser for help on using the repository browser.