PSAPROC2 ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;7/23/97
 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**34,50,70**; 10/24/97;Build 12
 ;This routine allows the user to edit invoices with errors or missing
 ;data.
 ;
CHK S PSA=+$O(PSAERR(0))
 I 'PSA W @IOF,!!,"There are no invoices that need to be processed." D END^PSAPROC Q
 ;
INV D HDR W !,"  More data is needed on the following invoices. Choose the invoices from",!,"  the list you want to edit.",!,PSASLN
 S (PSACNT,PSAMENU,PSASTOP)=0
 F  S PSAMENU=+$O(PSAERR(PSAMENU)) Q:'PSAMENU!(PSAOUT)  D  Q:PSASTOP
 .I $Y+4>IOSL D HEADER Q:PSASTOP
 .S PSAORD=$P(PSAERR(PSAMENU),"^"),PSAINV=$P(PSAERR(PSAMENU),"^",2),PSACTRL=$P(PSAERR(PSAMENU),"^",3),PSACNT=PSACNT+1
 .W !?2,PSAMENU_". ",?6,"Order#: "_PSAORD_"  Invoice#: "_PSAINV_"  Invoice Date: "_$$FMTE^XLFDT(+^XTMP("PSAPV",PSACTRL,"IN"))
 W !,PSASLN K DIR,PSASTOP
 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 processed or a range of numbers." W !
 S DIR("??")="^D SELHELP^PSAPROC2" D ^DIR K DIR I $G(DIRUT) S PSAOUT=1 Q
 S PSASEL=Y
 D PLOCK^PSAPROC8(2)  ;; < PSA*3*70 RJS
 I '$G(PSASEL) G EXIT^PSAPROC
 ;
PROC W ! S DIR("A",1)="Do you want to select the line items to be edited (S) or",DIR("A")="have them automatically (A) displayed for you?",DIR("B")="A",DIR(0)="SB^S:Select;A:Automatically displayed"
 S DIR("?",1)="Enter ""S"" to allow you to select the line items to be edited.",DIR("?",2)="Enter ""A"" to automatically receive prompts for the line items",DIR("?")="that need editing."
 D ^DIR K DIR I $G(DIRUT) S PSAOUT=1 Q
 G:Y="S" SEL^PSAPROC6
 ;
AUTO ;Process line items
 F PSAPC=1:1 S PSAMENU=$P(PSASEL,",",PSAPC) Q:'PSAMENU!(PSAOUT)  D  Q:PSAOUT
 .Q:'$D(PSAERR(PSAMENU))
 .S PSACTRL=$P(PSAERR(PSAMENU),"^",3),(PSALNCNT,PSALINES,PSACS,PSALLSUP)=0
 .Q:'$D(^XTMP("PSAPV",PSACTRL,"IN"))!('$D(^XTMP("PSAPV",PSACTRL,"IT")))
 .S PSAIN=^XTMP("PSAPV",PSACTRL,"IN"),PSALOC=+$P(PSAIN,"^",7),PSAMV=+$P(PSAIN,"^",12)
 .D HDR W !,"Order#: "_$P(PSAIN,"^",4)_"  Invoice#: "_$P(PSAIN,"^",2)_"  Invoice Date: "_$$FMTE^XLFDT(+PSAIN),!,PSASLN
 .W:$P(PSAIN,"^",9)="CS" !!,"MASTER VAULT: "_$S(PSAMV:$P($G(^PSD(58.8,PSAMV,0)),"^"),1:"Blank")
 .I $P(PSAIN,"^",10)="" D
 ..D SITES^PSAUTL1 S PSALOCN=$S($D(^PSD(58.8,PSALOC,0)):$P($G(^PSD(58.8,PSALOC,0)),"^"),1:"UNKNOWN")_PSACOMB
 ..W !!,"PHARMACY LOCATION: " I 'PSALOC W "Blank" Q
 ..W:$L(PSALOCN)>76 !,$P(PSALOCN,"(IP)",1)_"(IP)",!?17,$P(PSALOCN,"(IP)",2) W:$L(PSALOCN)<77 !,PSALOCN
 .W ! S PSARECD=$S(+$P(PSAIN,"^",11):+$P(PSAIN,"^",11),+$P(PSAIN,"^",6):+$P(PSAIN,"^",6),1:"") D RECD^PSAPROC3 Q:PSAOUT
 .;
 .;Gets & processes the line items
 .S PSALINE="" F  S PSALINE=$O(^XTMP("PSAPV",PSACTRL,"IT",PSALINE)) Q:PSALINE=""!(PSAOUT)  D  Q:PSAOUT
 ..S PSALNCNT=PSALNCNT+1,(PSAPASS,PSASUPP)=0,PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
 ..I $P(PSADATA,"^",18)="OK"!($P(PSADATA,"^",18)="P") S:$P(PSADATA,"^",18)="OK" $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",18)="P" S PSALINES=PSALINES+1 S:$P(PSADATA,"^",19)="CS" PSACS=PSACS+1 Q
 ..S PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
 ..S PSAIEN=$S(+$P(PSADATA,"^",15):+$P(PSADATA,"^",15),1:+$P(PSADATA,"^",6)),PSASUB=+$P(PSADATA,"^",7),PSANDC=$P($P(PSADATA,"^",4),"~"),PSAVSN=$P($P(PSADATA,"^",5),"~")
 ..D EDITDISP^PSAUTL1 D ^PSAPROC9
 .D:'PSAOUT SETINV
 Q:PSAOUT
 I '$O(PSAERR(0)) Q  ;*50 rid select (1-0)
 W @IOF,!,"If you are changing the status of an invoice to Processed, this is the",!,"last time you will be allowed to edit it before it goes to the verifier."
 W !,"If you are not changing the status of an invoice to Processed, you can",!,"edit it now.",!!,"You can edit the invoice's delivery date, pharmacy location, master vault,"
 W !,"and the line item's drug, quantity received, order unit, and dispense units",!,"per order unit. The reorder level can be edited if the pharmacy location or"
 W !,"master vault is set up to track the reorder levels.",!
 S DIR(0)="Y",DIR("A")="Edit invoices",DIR("B")="N",DIR("?",1)="Enter Yes to edit the invoices you just processed.",DIR("?",1)="Enter No to accept the invoices as they are now."
 S DIR("??")="^D EDIT^PSAPROC2" D ^DIR K DIR I $G(DIRUT)!('Y) S PSAOUT=1 Q
 ;
EDITINV ;Edits the invoice before placing in Processed status.
 K PSAERR S (PSACTRL,PSAERR,PSAOUT)=0
 F  S PSACTRL=$O(^XTMP("PSAPV",PSACTRL)) Q:PSACTRL=""  D
 .S:$D(^XTMP("PSAPV",PSACTRL,"IN")) PSAERR=PSAERR+1,PSAERR(PSAERR)=$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",4)_"^"_$P(^("IN"),"^",2)_"^"_PSACTRL_"^"_$P(^("IN"),"^",7)_"^"_$P(^("IN"),"^",12)
 ;
 W @IOF,!?26,"<<< EDIT INVOICE SCREEN >>>"
 W !!,"Choose the invoices to be edited. You can edit the invoice's date received and",!,"the line item's drug, quantity received, and order unit. The reorder and"
 W !,"stock levels can be edited if the pharmacy location or master vault is set",!,"up to maintain the reorder levels.",!,PSASLN,!
 S (PSACNT,PSAMENU,PSASTOP)=0
 F  S PSAMENU=+$O(PSAERR(PSAMENU)) Q:'PSAMENU!(PSAOUT)  D  Q:PSASTOP
 .I $Y+4>IOSL D HDR1 Q:PSASTOP
 .S PSAORD=$P(PSAERR(PSAMENU),"^"),PSAINV=$P(PSAERR(PSAMENU),"^",2),PSACTRL=$P(PSAERR(PSAMENU),"^",3),PSACNT=PSACNT+1
 .W !?1,PSACNT_".",?4,"Order#: "_PSAORD_"  Invoice#: "_PSAINV_"  Invoice Date: "_$$FMTE^XLFDT(+^XTMP("PSAPV",PSACTRL,"IN"))
 K PSASTOP
 S DIR(0)="LO^1:"_PSACNT,DIR("A")="Select invoices",DIR("?",1)="Enter the number to the left of the invoice",DIR("?")="data to be edited or a range of numbers." W !
 S DIR("??")="^D SEL^PSAPROC2" D ^DIR K DIR S:Y="" DUOUT=1 I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q  ;*50
 S PSASEL=Y D ^PSAPROC6
 Q
HDR ;Screen header
 W @IOF,!?19,"<<< EDIT INVOICES TO BE PROCESSED SCREEN >>>",!
 Q
 ;
HDR1 ;Screen header with hold
 S PSASS=21-$Y F PSAKK=1:1:PSASS W !
 S DIR(0)="E" D ^DIR K DIR I $G(DIRUT) S PSASTOP=1 Q
 W @IOF,!?26,"<<< EDIT INVOICE SCREEN >>>",!!,PSASLN
 Q
 ;
 S PSASS=21-$Y F PSAKK=1:1:PSASS W !
 S DIR(0)="E" D ^DIR K DIR I $G(DIRUT) S PSASTOP=1 Q
 W @IOF,!?19,"<<< EDIT INVOICES TO BE PROCESSED SCREEN >>>",!!,PSASLN
 Q
 ;
SETINV ;Sets invoice to processed if okay.
 S PSAOK=1
 I PSALLSUP=PSALNCNT S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",7)="",$P(^("IN"),"^",9)="",$P(^("IN"),"^",10)="",$P(^("IN"),"^",12)="",$P(^("IN"),"^",13)="SUP",PSAOK=1 G STATUS
 E  S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",13)=""
 I PSACS D  Q:PSAOUT
 .S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",9)="CS"
 .I $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)="" S PSACS(PSACTRL)="" D MASTER^PSAPROC9 Q:PSAOUT  S:$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)="" PSAOK=0
 .I PSACS=PSALNCNT S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)="ALL CS" Q
 .I PSACS'=PSALNCNT S $P(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)=""
 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=0
 ;
STATUS I PSALNCNT=PSALINES!(PSALNCNT=PSALLSUP),PSAOK D CHG^PSAPROC6,END^PSAPROC Q
 E  W !!,"** The invoice has not been placed in a Processed status!"
 D END^PSAPROC
 Q
EDIT ;Extended help for 'edit any invoices'
 W !?5,"If you answer Yes, a list of the invoices you were able to process will",!?5,"be displayed. You will be able to select the invoices to be edited then"
 W !?5,"the line item numbers. You will be able to edit the date the invoice was",!?5,"received, drug, quantity, order unit, and dispense units per order unit."
 W !?5,"If the drugs are assigned to a pharmacy location or master vault that",!?5,"maintains reorder levels, you will also be able to edit the reorder and",!?5,"stock levels.",!!?5,"Enter No if the invoice are correct."
 Q
SEL ;Extended help to 'Select invoices to process'
 W !?5,"Enter the number to the left of the invoice data that you want to process."
 Q
SELHELP ;Extended help to 'Select invoices to edit'
 W !?5,"Enter the number to the left of the invoice data that you want to",!?5,"edit. The line items will be displayed for you to select the ones"
 W !?5,"you want to edit. You are given this opportunity to edit the invoice",!?5,"because the automatic display may not catch all the needed corrections."
 W !!?5,"For example, the quantity on the invoice may be 6, but one bottle may",!?5,"be broken. Six is a valid quantity that the automatic display will not"
 W !?5,"realize as being incorrect. By answering Yes, you will be allowed to change",!?5,"the quantity to 5."
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSAPROC2   8509     printed  Sep 23, 2025@19:26:08                                                                                                                                                                                                    Page 2
PSAPROC2  ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;7/23/97
 +1       ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**34,50,70**; 10/24/97;Build 12
 +2       ;This routine allows the user to edit invoices with errors or missing
 +3       ;data.
 +4       ;
CHK        SET PSA=+$ORDER(PSAERR(0))
 +1        IF 'PSA
               WRITE @IOF,!!,"There are no invoices that need to be processed."
               DO END^PSAPROC
               QUIT 
 +2       ;
INV        DO HDR
           WRITE !,"  More data is needed on the following invoices. Choose the invoices from",!,"  the list you want to edit.",!,PSASLN
 +1        SET (PSACNT,PSAMENU,PSASTOP)=0
 +2        FOR 
               SET PSAMENU=+$ORDER(PSAERR(PSAMENU))
               if 'PSAMENU!(PSAOUT)
                   QUIT 
               Begin DoDot:1
 +3                IF $Y+4>IOSL
                       DO HEADER
                       if PSASTOP
                           QUIT 
 +4                SET PSAORD=$PIECE(PSAERR(PSAMENU),"^")
                   SET PSAINV=$PIECE(PSAERR(PSAMENU),"^",2)
                   SET PSACTRL=$PIECE(PSAERR(PSAMENU),"^",3)
                   SET PSACNT=PSACNT+1
 +5                WRITE !?2,PSAMENU_". ",?6,"Order#: "_PSAORD_"  Invoice#: "_PSAINV_"  Invoice Date: "_$$FMTE^XLFDT(+^XTMP("PSAPV",PSACTRL,"IN"))
               End DoDot:1
               if PSASTOP
                   QUIT 
 +6        WRITE !,PSASLN
           KILL DIR,PSASTOP
 +7        SET DIR(0)="LO^1:"_PSACNT
           SET DIR("A")="Select invoices to edit"
           SET DIR("?",1)="Enter the number to the left of the invoice"
           SET DIR("?")="data to be processed or a range of numbers."
           WRITE !
 +8        SET DIR("??")="^D SELHELP^PSAPROC2"
           DO ^DIR
           KILL DIR
           IF $GET(DIRUT)
               SET PSAOUT=1
               QUIT 
 +9        SET PSASEL=Y
 +10      ;; < PSA*3*70 RJS
           DO PLOCK^PSAPROC8(2)
 +11       IF '$GET(PSASEL)
               GOTO EXIT^PSAPROC
 +12      ;
PROC       WRITE !
           SET DIR("A",1)="Do you want to select the line items to be edited (S) or"
           SET DIR("A")="have them automatically (A) displayed for you?"
           SET DIR("B")="A"
           SET DIR(0)="SB^S:Select;A:Automatically displayed"
 +1        SET DIR("?",1)="Enter ""S"" to allow you to select the line items to be edited."
           SET DIR("?",2)="Enter ""A"" to automatically receive prompts for the line items"
           SET DIR("?")="that need editing."
 +2        DO ^DIR
           KILL DIR
           IF $GET(DIRUT)
               SET PSAOUT=1
               QUIT 
 +3        if Y="S"
               GOTO SEL^PSAPROC6
 +4       ;
AUTO      ;Process line items
 +1        FOR PSAPC=1:1
               SET PSAMENU=$PIECE(PSASEL,",",PSAPC)
               if 'PSAMENU!(PSAOUT)
                   QUIT 
               Begin DoDot:1
 +2                if '$DATA(PSAERR(PSAMENU))
                       QUIT 
 +3                SET PSACTRL=$PIECE(PSAERR(PSAMENU),"^",3)
                   SET (PSALNCNT,PSALINES,PSACS,PSALLSUP)=0
 +4                if '$DATA(^XTMP("PSAPV",PSACTRL,"IN"))!('$DATA(^XTMP("PSAPV",PSACTRL,"IT")))
                       QUIT 
 +5                SET PSAIN=^XTMP("PSAPV",PSACTRL,"IN")
                   SET PSALOC=+$PIECE(PSAIN,"^",7)
                   SET PSAMV=+$PIECE(PSAIN,"^",12)
 +6                DO HDR
                   WRITE !,"Order#: "_$PIECE(PSAIN,"^",4)_"  Invoice#: "_$PIECE(PSAIN,"^",2)_"  Invoice Date: "_$$FMTE^XLFDT(+PSAIN),!,PSASLN
 +7                if $PIECE(PSAIN,"^",9)="CS"
                       WRITE !!,"MASTER VAULT: "_$SELECT(PSAMV:$PIECE($GET(^PSD(58.8,PSAMV,0)),"^"),1:"Blank")
 +8                IF $PIECE(PSAIN,"^",10)=""
                       Begin DoDot:2
 +9                        DO SITES^PSAUTL1
                           SET PSALOCN=$SELECT($DATA(^PSD(58.8,PSALOC,0)):$PIECE($GET(^PSD(58.8,PSALOC,0)),"^"),1:"UNKNOWN")_PSACOMB
 +10                       WRITE !!,"PHARMACY LOCATION: "
                           IF 'PSALOC
                               WRITE "Blank"
                               QUIT 
 +11                       if $LENGTH(PSALOCN)>76
                               WRITE !,$PIECE(PSALOCN,"(IP)",1)_"(IP)",!?17,$PIECE(PSALOCN,"(IP)",2)
                           if $LENGTH(PSALOCN)<77
                               WRITE !,PSALOCN
                       End DoDot:2
 +12               WRITE !
                   SET PSARECD=$SELECT(+$PIECE(PSAIN,"^",11):+$PIECE(PSAIN,"^",11),+$PIECE(PSAIN,"^",6):+$PIECE(PSAIN,"^",6),1:"")
                   DO RECD^PSAPROC3
                   if PSAOUT
                       QUIT 
 +13      ;
 +14      ;Gets & processes the line items
 +15               SET PSALINE=""
                   FOR 
                       SET PSALINE=$ORDER(^XTMP("PSAPV",PSACTRL,"IT",PSALINE))
                       if PSALINE=""!(PSAOUT)
                           QUIT 
                       Begin DoDot:2
 +16                       SET PSALNCNT=PSALNCNT+1
                           SET (PSAPASS,PSASUPP)=0
                           SET PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
 +17                       IF $PIECE(PSADATA,"^",18)="OK"!($PIECE(PSADATA,"^",18)="P")
                               if $PIECE(PSADATA,"^",18)="OK"
                                   SET $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",18)="P"
                               SET PSALINES=PSALINES+1
                               if $PIECE(PSADATA,"^",19)="CS"
                                   SET PSACS=PSACS+1
                               QUIT 
 +18                       SET PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
 +19                       SET PSAIEN=$SELECT(+$PIECE(PSADATA,"^",15):+$PIECE(PSADATA,"^",15),1:+$PIECE(PSADATA,"^",6))
                           SET PSASUB=+$PIECE(PSADATA,"^",7)
                           SET PSANDC=$PIECE($PIECE(PSADATA,"^",4),"~")
                           SET PSAVSN=$PIECE($PIECE(PSADATA,"^",5),"~")
 +20                       DO EDITDISP^PSAUTL1
                           DO ^PSAPROC9
                       End DoDot:2
                       if PSAOUT
                           QUIT 
 +21               if 'PSAOUT
                       DO SETINV
               End DoDot:1
               if PSAOUT
                   QUIT 
 +22       if PSAOUT
               QUIT 
 +23      ;*50 rid select (1-0)
           IF '$ORDER(PSAERR(0))
               QUIT 
 +24       WRITE @IOF,!,"If you are changing the status of an invoice to Processed, this is the",!,"last time you will be allowed to edit it before it goes to the verifier."
 +25       WRITE !,"If you are not changing the status of an invoice to Processed, you can",!,"edit it now.",!!,"You can edit the invoice's delivery date, pharmacy location, master vault,"
 +26       WRITE !,"and the line item's drug, quantity received, order unit, and dispense units",!,"per order unit. The reorder level can be edited if the pharmacy location or"
 +27       WRITE !,"master vault is set up to track the reorder levels.",!
 +28       SET DIR(0)="Y"
           SET DIR("A")="Edit invoices"
           SET DIR("B")="N"
           SET DIR("?",1)="Enter Yes to edit the invoices you just processed."
           SET DIR("?",1)="Enter No to accept the invoices as they are now."
 +29       SET DIR("??")="^D EDIT^PSAPROC2"
           DO ^DIR
           KILL DIR
           IF $GET(DIRUT)!('Y)
               SET PSAOUT=1
               QUIT 
 +30      ;
EDITINV   ;Edits the invoice before placing in Processed status.
 +1        KILL PSAERR
           SET (PSACTRL,PSAERR,PSAOUT)=0
 +2        FOR 
               SET PSACTRL=$ORDER(^XTMP("PSAPV",PSACTRL))
               if PSACTRL=""
                   QUIT 
               Begin DoDot:1
 +3                if $DATA(^XTMP("PSAPV",PSACTRL,"IN"))
                       SET PSAERR=PSAERR+1
                       SET PSAERR(PSAERR)=$PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",4)_"^"_$PIECE(^("IN"),"^",2)_"^"_PSACTRL_"^"_$PIECE(^("IN"),"^",7)_"^"_$PIECE(^("IN"),"^",12)
               End DoDot:1
 +4       ;
 +5        WRITE @IOF,!?26,"<<< EDIT INVOICE SCREEN >>>"
 +6        WRITE !!,"Choose the invoices to be edited. You can edit the invoice's date received and",!,"the line item's drug, quantity received, and order unit. The reorder and"
 +7        WRITE !,"stock levels can be edited if the pharmacy location or master vault is set",!,"up to maintain the reorder levels.",!,PSASLN,!
 +8        SET (PSACNT,PSAMENU,PSASTOP)=0
 +9        FOR 
               SET PSAMENU=+$ORDER(PSAERR(PSAMENU))
               if 'PSAMENU!(PSAOUT)
                   QUIT 
               Begin DoDot:1
 +10               IF $Y+4>IOSL
                       DO HDR1
                       if PSASTOP
                           QUIT 
 +11               SET PSAORD=$PIECE(PSAERR(PSAMENU),"^")
                   SET PSAINV=$PIECE(PSAERR(PSAMENU),"^",2)
                   SET PSACTRL=$PIECE(PSAERR(PSAMENU),"^",3)
                   SET PSACNT=PSACNT+1
 +12               WRITE !?1,PSACNT_".",?4,"Order#: "_PSAORD_"  Invoice#: "_PSAINV_"  Invoice Date: "_$$FMTE^XLFDT(+^XTMP("PSAPV",PSACTRL,"IN"))
               End DoDot:1
               if PSASTOP
                   QUIT 
 +13       KILL PSASTOP
 +14       SET DIR(0)="LO^1:"_PSACNT
           SET DIR("A")="Select invoices"
           SET DIR("?",1)="Enter the number to the left of the invoice"
           SET DIR("?")="data to be edited or a range of numbers."
           WRITE !
 +15      ;*50
           SET DIR("??")="^D SEL^PSAPROC2"
           DO ^DIR
           KILL DIR
           if Y=""
               SET DUOUT=1
           IF $GET(DTOUT)!($GET(DUOUT))
               SET PSAOUT=1
               QUIT 
 +16       SET PSASEL=Y
           DO ^PSAPROC6
 +17       QUIT 
HDR       ;Screen header
 +1        WRITE @IOF,!?19,"<<< EDIT INVOICES TO BE PROCESSED SCREEN >>>",!
 +2        QUIT 
 +3       ;
HDR1      ;Screen header with hold
 +1        SET PSASS=21-$Y
           FOR PSAKK=1:1:PSASS
               WRITE !
 +2        SET DIR(0)="E"
           DO ^DIR
           KILL DIR
           IF $GET(DIRUT)
               SET PSASTOP=1
               QUIT 
 +3        WRITE @IOF,!?26,"<<< EDIT INVOICE SCREEN >>>",!!,PSASLN
 +4        QUIT 
 +5       ;
 +1        SET PSASS=21-$Y
           FOR PSAKK=1:1:PSASS
               WRITE !
 +2        SET DIR(0)="E"
           DO ^DIR
           KILL DIR
           IF $GET(DIRUT)
               SET PSASTOP=1
               QUIT 
 +3        WRITE @IOF,!?19,"<<< EDIT INVOICES TO BE PROCESSED SCREEN >>>",!!,PSASLN
 +4        QUIT 
 +5       ;
SETINV    ;Sets invoice to processed if okay.
 +1        SET PSAOK=1
 +2        IF PSALLSUP=PSALNCNT
               SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",7)=""
               SET $PIECE(^("IN"),"^",9)=""
               SET $PIECE(^("IN"),"^",10)=""
               SET $PIECE(^("IN"),"^",12)=""
               SET $PIECE(^("IN"),"^",13)="SUP"
               SET PSAOK=1
               GOTO STATUS
 +3       IF '$TEST
               SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",13)=""
 +4        IF PSACS
               Begin DoDot:1
 +5                SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",9)="CS"
 +6                IF $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)=""
                       SET PSACS(PSACTRL)=""
                       DO MASTER^PSAPROC9
                       if PSAOUT
                           QUIT 
                       if $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",12)=""
                           SET PSAOK=0
 +7                IF PSACS=PSALNCNT
                       SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)="ALL CS"
                       QUIT 
 +8                IF PSACS'=PSALNCNT
                       SET $PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",10)=""
               End DoDot:1
               if PSAOUT
                   QUIT 
 +9        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=0
 +10      ;
STATUS     IF PSALNCNT=PSALINES!(PSALNCNT=PSALLSUP)
               IF PSAOK
                   DO CHG^PSAPROC6
                   DO END^PSAPROC
                   QUIT 
 +1       IF '$TEST
               WRITE !!,"** The invoice has not been placed in a Processed status!"
 +2        DO END^PSAPROC
 +3        QUIT 
EDIT      ;Extended help for 'edit any invoices'
 +1        WRITE !?5,"If you answer Yes, a list of the invoices you were able to process will",!?5,"be displayed. You will be able to select the invoices to be edited then"
 +2        WRITE !?5,"the line item numbers. You will be able to edit the date the invoice was",!?5,"received, drug, quantity, order unit, and dispense units per order unit."
 +3        WRITE !?5,"If the drugs are assigned to a pharmacy location or master vault that",!?5,"maintains reorder levels, you will also be able to edit the reorder and",!?5,"stock levels.",!!?5,"Enter No if the invoice are correct."
 +4        QUIT 
SEL       ;Extended help to 'Select invoices to process'
 +1        WRITE !?5,"Enter the number to the left of the invoice data that you want to process."
 +2        QUIT 
SELHELP   ;Extended help to 'Select invoices to edit'
 +1        WRITE !?5,"Enter the number to the left of the invoice data that you want to",!?5,"edit. The line items will be displayed for you to select the ones"
 +2        WRITE !?5,"you want to edit. You are given this opportunity to edit the invoice",!?5,"because the automatic display may not catch all the needed corrections."
 +3        WRITE !!?5,"For example, the quantity on the invoice may be 6, but one bottle may",!?5,"be broken. Six is a valid quantity that the automatic display will not"
 +4        WRITE !?5,"realize as being incorrect. By answering Yes, you will be allowed to change",!?5,"the quantity to 5."
 +5        QUIT