PSALOGON ;BIR/JMB-Logon Utility ;7/23/97
;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;; 10/24/97
;This routine displays the number of invoices the user needs to process
;or verify when the user signs on the system. The PSALOGON option needs
;to be placed on the system that the users signon to. Then PSA ORDERS
;ALERT option needs to be added as an item to the XU USER SIGN-ON
;option.
;
SIGNON Q:'$D(^XUSEC("PSA ORDERS",DUZ))
S (PSACNTP,PSACTRL)=0
F S PSACTRL=$O(^XTMP("PSAPV",PSACTRL)) Q:'PSACTRL D
.Q:'$D(^XTMP("PSAPV",PSACTRL,"IN"))
.S:$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",8)'="P" PSACNTP=PSACNTP+1
VERIFY S (PSACNTV,PSAORD)=0
F S PSAORD=$O(^PSD(58.811,"ASTAT","P",PSAORD)) Q:'PSAORD D
.S PSAINV=0 F S PSAINV=$O(^PSD(58.811,"ASTAT","P",PSAORD,PSAINV)) Q:'PSAINV D
..Q:+$P($G(^PSD(58.811,PSAORD,1,PSAINV,0)),"^",10)=DUZ
..I $P($G(^PSD(58.811,PSAORD,1,PSAINV,0)),"^",8)="S"!($P($G(^PSD(58.811,PSAORD,0)),"^",8)="A"),'$D(^XUSEC("PSJ RPHARM",DUZ)) Q
..S PSACNTV=PSACNTV+1
G:'PSACNTP&('PSACNTV) EXIT
I PSACNTP,PSACNTV S PSAMSG="!There "_$S(PSACNTP>1:"are "_PSACNTP_" invoices",1:"is 1 invoice")_" to process and "_$S(PSACNTV>1:PSACNTV_" invoices",1:"1 invoice")_" to verify." G SEND
I PSACNTP S:PSACNTP>1 PSAMSG="!There are "_PSACNTP_" invoices to process." S:PSACNTP=1 PSAMSG="!There is 1 invoice to process." G SEND
I PSACNTV S:PSACNTV>1 PSAMSG="!There are "_PSACNTV_" invoices to verify." S:PSACNTV=1 PSAMSG="!There is 1 invoice to verify." G SEND
Q
;
SEND D SET^XUS1A(PSAMSG)
;
EXIT K PSACNTP,PSACNTV,PSACTRL,PSAINV,PSAMSG,PSAORD
Q
PSALOGON ;BIR/JMB-Logon Utility ;7/23/97
+1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;; 10/24/97
+2 ;This routine displays the number of invoices the user needs to process
+3 ;or verify when the user signs on the system. The PSALOGON option needs
+4 ;to be placed on the system that the users signon to. Then PSA ORDERS
+5 ;ALERT option needs to be added as an item to the XU USER SIGN-ON
+6 ;option.
+7 ;
SIGNON IF '$DATA(^XUSEC("PSA ORDERS",DUZ))
QUIT
+1 SET (PSACNTP,PSACTRL)=0
+2 FOR
SET PSACTRL=$ORDER(^XTMP("PSAPV",PSACTRL))
IF 'PSACTRL
QUIT
Begin DoDot:1
+3 IF '$DATA(^XTMP("PSAPV",PSACTRL,"IN"))
QUIT
+4 IF $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",8)'="P"
SET PSACNTP=PSACNTP+1
End DoDot:1
VERIFY SET (PSACNTV,PSAORD)=0
+1 FOR
SET PSAORD=$ORDER(^PSD(58.811,"ASTAT","P",PSAORD))
IF 'PSAORD
QUIT
Begin DoDot:1
+2 SET PSAINV=0
FOR
SET PSAINV=$ORDER(^PSD(58.811,"ASTAT","P",PSAORD,PSAINV))
IF 'PSAINV
QUIT
Begin DoDot:2
+3 IF +$PIECE($GET(^PSD(58.811,PSAORD,1,PSAINV,0)),"^",10)=DUZ
QUIT
+4 IF $PIECE($GET(^PSD(58.811,PSAORD,1,PSAINV,0)),"^",8)="S"!($PIECE($GET(^PSD(58.811,PSAORD,0)),"^",8)="A")
IF '$DATA(^XUSEC("PSJ RPHARM",DUZ))
QUIT
+5 SET PSACNTV=PSACNTV+1
End DoDot:2
End DoDot:1
+6 IF 'PSACNTP&('PSACNTV)
GOTO EXIT
+7 IF PSACNTP
IF PSACNTV
SET PSAMSG="!There "_$SELECT(PSACNTP>1:"are "_PSACNTP_" invoices",1:"is 1 invoice")_" to process and "_$SELECT(PSACNTV>1:PSACNTV_" invoices",1:"1 invoice")_" to verify."
GOTO SEND
+8 IF PSACNTP
IF PSACNTP>1
SET PSAMSG="!There are "_PSACNTP_" invoices to process."
IF PSACNTP=1
SET PSAMSG="!There is 1 invoice to process."
GOTO SEND
+9 IF PSACNTV
IF PSACNTV>1
SET PSAMSG="!There are "_PSACNTV_" invoices to verify."
IF PSACNTV=1
SET PSAMSG="!There is 1 invoice to verify."
GOTO SEND
+10 QUIT
+11 ;
SEND DO SET^XUS1A(PSAMSG)
+1 ;
EXIT KILL PSACNTP,PSACNTV,PSACTRL,PSAINV,PSAMSG,PSAORD
+1 QUIT