PSAPROC1 ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;7/23/97
;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**12,21**; 10/24/97
;This routine processes uploaded invoices.
;
CHK ;Check for invoices with a status of "OK" (uploaded & error free)
;& status of "" (uploaded & errors).
K PSA,PSAOK S (PSACNTOK,PSACNTER,PSACTRL)=0
F S PSACTRL=$O(^XTMP("PSAPV",PSACTRL)) Q:PSACTRL="" D
.;DAVE B (PSA*3*12 13MAY99) Restrict to appropriate division
.I $G(PSASORT)'=0,$G(PSASORT)'="",$D(^XTMP("PSAPV",PSACTRL,"ST")),$P(^XTMP("PSAPV",PSACTRL,"ST"),"^",1)'=PSASORT Q
.Q:'$D(^XTMP("PSAPV",PSACTRL,"IN")) S PSAIN=^XTMP("PSAPV",PSACTRL,"IN")
.I $P(PSAIN,"^",8)="OK"!($P(PSAIN,"^",13)="SUP") D Q
..I $P(PSAIN,"^",10)="ALL CS",$P(PSAIN,"^",12)'="" D OK Q
..I $P(PSAIN,"^",10)'="ALL CS",$P(PSAIN,"^",9)="CS",$P(PSAIN,"^",12)'="",$P(PSAIN,"^",7)'="" D OK Q
..I $P(PSAIN,"^",10)'="ALL CS",$P(PSAIN,"^",9)'="CS",$P(PSAIN,"^",7)'="" D OK Q
..S PSACNTER=PSACNTER+1,PSAERR(PSACNTER)=$P(PSAIN,"^",4)_"^"_$P(PSAIN,"^",2)_"^"_PSACTRL_"^"_$P(PSAIN,"^",7)
.I $P(PSAIN,"^",8)="" S PSACNTER=PSACNTER+1,PSAERR(PSACNTER)=$P(PSAIN,"^",4)_"^"_$P(PSAIN,"^",2)_"^"_PSACTRL_"^"_$P(PSAIN,"^",7)
S PSA=+$O(PSAOK(0))
G:'PSA ^PSAPROC2
;
NOERROR ;Display list of invoices that can be processed by selecting
;invoice number.
W @IOF,!?21,"<<< PROCESS ENTIRE INVOICE SCREEN >>>"
W !!?2,"No errors have been detected on the following invoices. If there are no",!?2,"corrections, you can change the invoices' status to ""Processed"" by"
W !?2,"selecting them from the list. If you do have corrections, press the return",!?2,"key then a second list will be displayed. You will be able to choose the",!?2,"invoices from that list and enter corrections."
W !!?2,"Choose the invoices from the list you want to process.",!,PSADLN
S (PSACNT,PSASTOP)=0,PSAMENU=""
F S PSAMENU=$O(PSAOK(PSAMENU)) Q:PSAMENU=""!(PSAOUT) D Q:PSASTOP
.I $Y+4>IOSL D HEADER Q:PSASTOP
.S PSAORD=$P(PSAOK(PSAMENU),"^"),PSAINV=$P(PSAOK(PSAMENU),"^",2),PSACTRL=$P(PSAOK(PSAMENU),"^",3),PSACNT=PSACNT+1
.W !?2,PSAMENU_". ",?4,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(+^XTMP("PSAPV",PSACTRL,"IN"))
K PSASTOP W !,PSADLN
S DIR(0)="LO^1:"_PSACNT,DIR("A")="Select invoices to process",DIR("?",1)="Enter the number to the left of the invoice",DIR("?")="data to be processed or a range of numbers." W !
S DIR("??")="^D SEL^PSAPROC1" D ^DIR K DIR G:Y="" EDIT I $G(DIRUT) S PSAOUT=1 Q
S PSASEL=Y
INVSEL F PSAPC=1:1 S PSA=+$P(PSASEL,",",PSAPC) Q:'PSA D Q:PSAOUT
.S PSACTRL=$P(PSAOK(PSA),"^",3) Q:'$D(^XTMP("PSAPV",PSACTRL,"IN"))
.S PSAIN=^XTMP("PSAPV",PSACTRL,"IN"),PSARECD=+$P(PSAIN,"^",6),PSALINES=0
.D PROCESS
Q:PSAOUT G:'+$O(PSAOK(0)) PROC2
EDIT ;Edit error free invoices
S PSA=0 F S PSA=$O(PSAOK(PSA)) Q:'PSA D
.I $P($G(^XTMP("PSAPV",$P(PSAOK(PSA),"^",3),"IN")),"^",8)="OK"!($P($G(^("IN")),"^",13)="SUP") D
..S PSACNTER=PSACNTER+1,PSAERR(PSACNTER)=$P(^XTMP("PSAPV",$P(PSAOK(PSA),"^",3),"IN"),"^",4)_"^"_$P(^("IN"),"^",2)_"^"_$P(PSAOK(PSA),"^",3)_"^"_$P(^("IN"),"^",7)
;
PROC2 I +$O(PSAERR(0)) D ^PSAPROC2
Q
;
S DIR(0)="E" D ^DIR K DIR I $G(DIRUT) S PSASTOP=1 Q
W @IOF,!?21,"<<< PROCESS ENTIRE INVOICE SCREEN >>>",!!,PSADLN
Q
;
PROCESS ;Get date recd & line item data
I $P(PSAIN,"^",13)="SUP" D HDR,SUPPLY^PSAPROC6 Q
D HDR,RECD^PSAPROC3 Q:PSAOUT S (PSACS,PSALNCNT)=0,PSALINE=""
F S PSALINE=$O(^XTMP("PSAPV",PSACTRL,"IT",PSALINE)) Q:PSALINE="" D Q:PSAOUT
.K PSAPHARM,PSAMV
.S PSALNCNT=PSALNCNT+1,(PSADISP,PSADU,PSAHDR)=0
.S PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE),PSAIEN=$S(+$P(PSADATA,"^",15):+$P(PSADATA,"^",15),+$P(PSADATA,"^",6):+$P(PSADATA,"^",6),1:0),PSASUB=+$P(PSADATA,"^",7)
.S:$P(PSADATA,"^",19)="CS" PSAMV=+$P(PSAIN,"^",12) S:$P(PSADATA,"^",19)'="CS" PSAPHARM=+$P(PSAIN,"^",7)
.S PSALOC=+$S($P(PSADATA,"^",19)="CS":PSAMV,1:PSAPHARM)
.I $P($G(^PSDRUG(PSAIEN,660)),"^",8)="" D:'PSAHDR HDR D:'PSADISP DISPLAY^PSAUTL1 D DU^PSAPROC8 Q:PSAOUT
.I '+$P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",7),$P($G(^PSDRUG(PSAIEN,660)),"^",8)'="" D:'PSAHDR HDR D:'PSADISP DISPLAY^PSAUTL1 D:PSASUB DUOU^PSAPROC8 D:'PSASUB DUOU^PSAPROC3 Q:PSAOUT
.I +$P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6)'=+$P(PSADATA,"^",3) D:'PSAHDR HDR D:'PSADISP DISPLAY^PSAUTL1 D PRICE^PSAPROC8 Q:PSAOUT
.I +$P($G(^PSD(58.8,PSALOC,0)),"^",14) D Q:PSAOUT
..I '+$P($G(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",3),'+$P(PSADATA,"^",27) D:'PSAHDR HDR D:'PSADISP DISPLAY^PSAUTL1 D STOCK^PSAPROC8 Q:PSAOUT
..I '+$P($G(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",5),'+$P(PSADATA,"^",21) D:'PSAHDR HDR D:'PSADISP DISPLAY^PSAUTL1 D REORDER^PSAPROC8
.D SETLINE^PSAPROC3 S:$P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",19)="CS" PSACS=PSACS+1
S PSAOK=0
CS I PSACS D Q:PSAOUT
.S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",9)="CS"
.I $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)="" K PSACS S PSACS(PSACTRL)="" D MASTER^PSAPROC9 Q:PSAOUT S:$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)'="" PSAOK=1
.I PSACS=PSALNCNT S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)="ALL CS" Q
.I PSACS'=PSALNCNT S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)=""
NCS I 'PSACS S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",9)="",$P(^("IN"),"^",10)="",$P(^("IN"),"^",12)="" D:$P(^("IN"),"^",7)="" GETLOC^PSAPROC9 Q:PSAOUT S:$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",7)'="" PSAOK=1
;
I PSALNCNT=PSALINES S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",8)="P" K PSAOK(PSACTRL) W !!,"The invoice status has been changed to Processed!" D ^PSAPROC7 ;PSA*3*21 (1/3/01- file immediately)
E W !!,"** The invoice has not been placed in a Processed status!"
D END^PSAPROC
Q
;
HDR ;Header for editing line items with missing data
S PSAHDR=1
W @IOF,!?21,"<<< PROCESS ENTIRE INVOICE SCREEN >>>",!,"Order#: "_$P(PSAIN,"^",4)_" Invoice#: "_$P(PSAIN,"^",2)_" Invoice Date: "_$$FMTE^XLFDT(+PSAIN),!,PSADLN
Q
OK ;Sets okay array
S PSACNTOK=PSACNTOK+1,PSAOK(PSACNTOK)=$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",4)_"^"_$P(^("IN"),"^",2)_"^"_PSACTRL_"^"_$P(^("IN"),"^",7)
Q
;
SEL ;Extended help to 'Select invoices'
W !?5,"Enter the number to the left of the invoice data that you want to process."
Q
PSAPROC1 ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;7/23/97
+1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**12,21**; 10/24/97
+2 ;This routine processes uploaded invoices.
+3 ;
CHK ;Check for invoices with a status of "OK" (uploaded & error free)
+1 ;& status of "" (uploaded & errors).
+2 KILL PSA,PSAOK
SET (PSACNTOK,PSACNTER,PSACTRL)=0
+3 FOR
SET PSACTRL=$ORDER(^XTMP("PSAPV",PSACTRL))
IF PSACTRL=""
QUIT
Begin DoDot:1
+4 ;DAVE B (PSA*3*12 13MAY99) Restrict to appropriate division
+5 IF $GET(PSASORT)'=0
IF $GET(PSASORT)'=""
IF $DATA(^XTMP("PSAPV",PSACTRL,"ST"))
IF $PIECE(^XTMP("PSAPV",PSACTRL,"ST"),"^",1)'=PSASORT
QUIT
+6 IF '$DATA(^XTMP("PSAPV",PSACTRL,"IN"))
QUIT
SET PSAIN=^XTMP("PSAPV",PSACTRL,"IN")
+7 IF $PIECE(PSAIN,"^",8)="OK"!($PIECE(PSAIN,"^",13)="SUP")
Begin DoDot:2
+8 IF $PIECE(PSAIN,"^",10)="ALL CS"
IF $PIECE(PSAIN,"^",12)'=""
DO OK
QUIT
+9 IF $PIECE(PSAIN,"^",10)'="ALL CS"
IF $PIECE(PSAIN,"^",9)="CS"
IF $PIECE(PSAIN,"^",12)'=""
IF $PIECE(PSAIN,"^",7)'=""
DO OK
QUIT
+10 IF $PIECE(PSAIN,"^",10)'="ALL CS"
IF $PIECE(PSAIN,"^",9)'="CS"
IF $PIECE(PSAIN,"^",7)'=""
DO OK
QUIT
+11 SET PSACNTER=PSACNTER+1
SET PSAERR(PSACNTER)=$PIECE(PSAIN,"^",4)_"^"_$PIECE(PSAIN,"^",2)_"^"_PSACTRL_"^"_$PIECE(PSAIN,"^",7)
End DoDot:2
QUIT
+12 IF $PIECE(PSAIN,"^",8)=""
SET PSACNTER=PSACNTER+1
SET PSAERR(PSACNTER)=$PIECE(PSAIN,"^",4)_"^"_$PIECE(PSAIN,"^",2)_"^"_PSACTRL_"^"_$PIECE(PSAIN,"^",7)
End DoDot:1
+13 SET PSA=+$ORDER(PSAOK(0))
+14 IF 'PSA
GOTO ^PSAPROC2
+15 ;
NOERROR ;Display list of invoices that can be processed by selecting
+1 ;invoice number.
+2 WRITE @IOF,!?21,"<<< PROCESS ENTIRE INVOICE SCREEN >>>"
+3 WRITE !!?2,"No errors have been detected on the following invoices. If there are no",!?2,"corrections, you can change the invoices' status to ""Processed"" by"
+4 WRITE !?2,"selecting them from the list. If you do have corrections, press the return",!?2,"key then a second list will be displayed. You will be able to choose the",!?2,"invoices from that list and enter corrections."
+5 WRITE !!?2,"Choose the invoices from the list you want to process.",!,PSADLN
+6 SET (PSACNT,PSASTOP)=0
SET PSAMENU=""
+7 FOR
SET PSAMENU=$ORDER(PSAOK(PSAMENU))
IF PSAMENU=""!(PSAOUT)
QUIT
Begin DoDot:1
+8 IF $Y+4>IOSL
DO HEADER
IF PSASTOP
QUIT
+9 SET PSAORD=$PIECE(PSAOK(PSAMENU),"^")
SET PSAINV=$PIECE(PSAOK(PSAMENU),"^",2)
SET PSACTRL=$PIECE(PSAOK(PSAMENU),"^",3)
SET PSACNT=PSACNT+1
+10 WRITE !?2,PSAMENU_". ",?4,"Order#: "_PSAORD_" Invoice#: "_PSAINV_" Invoice Date: "_$$FMTE^XLFDT(+^XTMP("PSAPV",PSACTRL,"IN"))
End DoDot:1
IF PSASTOP
QUIT
+11 KILL PSASTOP
WRITE !,PSADLN
+12 SET DIR(0)="LO^1:"_PSACNT
SET DIR("A")="Select invoices to process"
SET DIR("?",1)="Enter the number to the left of the invoice"
SET DIR("?")="data to be processed or a range of numbers."
WRITE !
+13 SET DIR("??")="^D SEL^PSAPROC1"
DO ^DIR
KILL DIR
IF Y=""
GOTO EDIT
IF $GET(DIRUT)
SET PSAOUT=1
QUIT
+14 SET PSASEL=Y
INVSEL FOR PSAPC=1:1
SET PSA=+$PIECE(PSASEL,",",PSAPC)
IF 'PSA
QUIT
Begin DoDot:1
+1 SET PSACTRL=$PIECE(PSAOK(PSA),"^",3)
IF '$DATA(^XTMP("PSAPV",PSACTRL,"IN"))
QUIT
+2 SET PSAIN=^XTMP("PSAPV",PSACTRL,"IN")
SET PSARECD=+$PIECE(PSAIN,"^",6)
SET PSALINES=0
+3 DO PROCESS
End DoDot:1
IF PSAOUT
QUIT
+4 IF PSAOUT
QUIT
IF '+$ORDER(PSAOK(0))
GOTO PROC2
EDIT ;Edit error free invoices
+1 SET PSA=0
FOR
SET PSA=$ORDER(PSAOK(PSA))
IF 'PSA
QUIT
Begin DoDot:1
+2 IF $PIECE($GET(^XTMP("PSAPV",$PIECE(PSAOK(PSA),"^",3),"IN")),"^",8)="OK"!($PIECE($GET(^("IN")),"^",13)="SUP")
Begin DoDot:2
+3 SET PSACNTER=PSACNTER+1
SET PSAERR(PSACNTER)=$PIECE(^XTMP("PSAPV",$PIECE(PSAOK(PSA),"^",3),"IN"),"^",4)_"^"_$PIECE(^("IN"),"^",2)_"^"_$PIECE(PSAOK(PSA),"^",3)_"^"_$PIECE(^("IN"),"^",7)
End DoDot:2
End DoDot:1
+4 ;
PROC2 IF +$ORDER(PSAERR(0))
DO ^PSAPROC2
+1 QUIT
+2 ;
FOR PSAKK=1:1:PSASS
WRITE !
+1 SET DIR(0)="E"
DO ^DIR
KILL DIR
IF $GET(DIRUT)
SET PSASTOP=1
QUIT
+2 WRITE @IOF,!?21,"<<< PROCESS ENTIRE INVOICE SCREEN >>>",!!,PSADLN
+3 QUIT
+4 ;
PROCESS ;Get date recd & line item data
+1 IF $PIECE(PSAIN,"^",13)="SUP"
DO HDR
DO SUPPLY^PSAPROC6
QUIT
+2 DO HDR
DO RECD^PSAPROC3
IF PSAOUT
QUIT
SET (PSACS,PSALNCNT)=0
SET PSALINE=""
+3 FOR
SET PSALINE=$ORDER(^XTMP("PSAPV",PSACTRL,"IT",PSALINE))
IF PSALINE=""
QUIT
Begin DoDot:1
+4 KILL PSAPHARM,PSAMV
+5 SET PSALNCNT=PSALNCNT+1
SET (PSADISP,PSADU,PSAHDR)=0
+6 SET PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
SET PSAIEN=$SELECT(+$PIECE(PSADATA,"^",15):+$PIECE(PSADATA,"^",15),+$PIECE(PSADATA,"^",6):+$PIECE(PSADATA,"^",6),1:0)
SET PSASUB=+$PIECE(PSADATA,"^",7)
+7 IF $PIECE(PSADATA,"^",19)="CS"
SET PSAMV=+$PIECE(PSAIN,"^",12)
IF $PIECE(PSADATA,"^",19)'="CS"
SET PSAPHARM=+$PIECE(PSAIN,"^",7)
+8 SET PSALOC=+$SELECT($PIECE(PSADATA,"^",19)="CS":PSAMV,1:PSAPHARM)
+9 IF $PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)=""
IF 'PSAHDR
DO HDR
IF 'PSADISP
DO DISPLAY^PSAUTL1
DO DU^PSAPROC8
IF PSAOUT
QUIT
+10 IF '+$PIECE($GET(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",7)
IF $PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)'=""
IF 'PSAHDR
DO HDR
IF 'PSADISP
DO DISPLAY^PSAUTL1
IF PSASUB
DO DUOU^PSAPROC8
IF 'PSASUB
DO DUOU^PSAPROC3
IF PSAOUT
QUIT
+11 IF +$PIECE($GET(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6)'=+$PIECE(PSADATA,"^",3)
IF 'PSAHDR
DO HDR
IF 'PSADISP
DO DISPLAY^PSAUTL1
DO PRICE^PSAPROC8
IF PSAOUT
QUIT
+12 IF +$PIECE($GET(^PSD(58.8,PSALOC,0)),"^",14)
Begin DoDot:2
+13 IF '+$PIECE($GET(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",3)
IF '+$PIECE(PSADATA,"^",27)
IF 'PSAHDR
DO HDR
IF 'PSADISP
DO DISPLAY^PSAUTL1
DO STOCK^PSAPROC8
IF PSAOUT
QUIT
+14 IF '+$PIECE($GET(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",5)
IF '+$PIECE(PSADATA,"^",21)
IF 'PSAHDR
DO HDR
IF 'PSADISP
DO DISPLAY^PSAUTL1
DO REORDER^PSAPROC8
End DoDot:2
IF PSAOUT
QUIT
+15 DO SETLINE^PSAPROC3
IF $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",19)="CS"
SET PSACS=PSACS+1
End DoDot:1
IF PSAOUT
QUIT
+16 SET PSAOK=0
CS IF PSACS
Begin DoDot:1
+1 SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",9)="CS"
+2 IF $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)=""
KILL PSACS
SET PSACS(PSACTRL)=""
DO MASTER^PSAPROC9
IF PSAOUT
QUIT
IF $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)'=""
SET PSAOK=1
+3 IF PSACS=PSALNCNT
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)="ALL CS"
QUIT
+4 IF PSACS'=PSALNCNT
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)=""
End DoDot:1
IF PSAOUT
QUIT
NCS IF 'PSACS
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",9)=""
SET $PIECE(^("IN"),"^",10)=""
SET $PIECE(^("IN"),"^",12)=""
IF $PIECE(^("IN"),"^",7)=""
DO GETLOC^PSAPROC9
IF PSAOUT
QUIT
IF $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",7)'=""
SET PSAOK=1
+1 ;
+2 ;PSA*3*21 (1/3/01- file immediately)
IF PSALNCNT=PSALINES
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",8)="P"
KILL PSAOK(PSACTRL)
WRITE !!,"The invoice status has been changed to Processed!"
DO ^PSAPROC7
+3 IF '$TEST
WRITE !!,"** The invoice has not been placed in a Processed status!"
+4 DO END^PSAPROC
+5 QUIT
+6 ;
HDR ;Header for editing line items with missing data
+1 SET PSAHDR=1
+2 WRITE @IOF,!?21,"<<< PROCESS ENTIRE INVOICE SCREEN >>>",!,"Order#: "_$PIECE(PSAIN,"^",4)_" Invoice#: "_$PIECE(PSAIN,"^",2)_" Invoice Date: "_$$FMTE^XLFDT(+PSAIN),!,PSADLN
+3 QUIT
OK ;Sets okay array
+1 SET PSACNTOK=PSACNTOK+1
SET PSAOK(PSACNTOK)=$PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",4)_"^"_$PIECE(^("IN"),"^",2)_"^"_PSACTRL_"^"_$PIECE(^("IN"),"^",7)
+2 QUIT
+3 ;
SEL ;Extended help to 'Select invoices'
+1 WRITE !?5,"Enter the number to the left of the invoice data that you want to process."
+2 QUIT