PSAPROC8 ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;7/23/97
;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**3**; 10/24/97
;This routine processes uploaded invoices.
;
DU ;Prompts Dispense Unit if blank
F L +^PSDRUG(PSAIEN,0):0 I Q
S DIE="^PSDRUG(",DA=PSAIEN,DR=14.5 D ^DIE K DIE L -^PSDRUG(PSAIEN,0)
I +$P($G(^PSDRUG(PSAIEN,660)),"^",8) D G DU
.F L +^PSDRUG(PSAIEN,0):0 I Q
.S DIE="^PSDRUG(",DA=PSAIEN,DR="14.5///@" D ^DIE K DIE L -^PSDRUG(PSAIEN,0)
I $P($G(^PSDRUG(PSAIEN,660)),"^",8)'="" S PSADU=1 Q
;
W !,"The dispense units must be entered to change",!,"the status of the invoice to Processed."
S DIR(0)="Y",DIR("B")="Y",DIR("A")="Do you want to enter the dispense units now",DIR("?",1)="Enter Yes to return to the DISPENSE UNIT prompt.",DIR("?")="Enter No to bypass entering the dispense units now."
S DIR("??")="^D DISPYN^PSAPROC8" D ^DIR K DIR I $G(DIRUT) S PSAOUT=1 Q
G:+Y DU
Q
;
DUOU ;Gets Dispense Units per Order Unit
W:'$G(PSADU) !,"DISPENSE UNITS: "_$P($G(^PSDRUG(PSAIEN,660)),"^",8)
S PSADU=1
F L +^PSDRUG(PSAIEN,0):0 I Q
S DIE="^PSDRUG("_PSAIEN_",1,",DA(1)=PSAIEN,DA=+PSASUB,DR=403 D ^DIE K DIE L -^PSDRUG(PSAIEN,0)
I $D(Y)!($G(DTOUT)) S PSAOUT=1 Q
Q:+$P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",7)
;
S DIR(0)="Y",DIR("B")="Y",DIR("A",1)="The dispense units per order unit must be entered to change the ",DIR("A")="status of the invoice to Processed. Do you want to enter the data now"
S DIR("?",1)="Enter Yes to return to the "_$P($G(^PSDRUG(PSAIEN,660)),"^",8)_"s per "_$P($G(^DIC(51.5,+$P($P(PSADATA,"^",2),"~",2),0)),"^",2)_" prompt."
S DIR("?")="Enter No to bypass entering the dispense units now.",DIR("??")="^D DUOUYN^PSAPROC8"
D ^DIR K DIR I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q
G:+Y DUOU
Q
OK ;
S PSACNTOK=PSACNTOK+1,PSAOK(PSACNTOK)=$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",4)_"^"_$P(^("IN"),"^",2)_"^"_PSACTRL_"^"_$P(^("IN"),"^",7)
Q
PRICE ;Price per Order Unit changed
S PSAIPR=$L($FN($P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",3),",",2)),PSAFPR=$L($FN($P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6),",",2))
S PSAJUST=$S(PSAIPR>PSAFPR:PSAIPR,1:PSAFPR)
W !!,"Price per Order Unit -- Invoice's: $"_$J($FN($P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",3),",",2),PSAJUST,2),!?24,"File's : $"_$J($FN($P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6),",",2),PSAJUST,2),!
S DIR(0)="Y",DIR("A")="Is the invoice's price per order unit correct",DIR("B")="Y",DIR("?",1)="Enter Yes if "_$P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",3)_" is correct."
S DIR("?")="Enter No to keep the file's price per order unit.",DIR("??")="^D PRICEOU^PSAPROC1" D ^DIR K DIR I $G(DIRUT) S PSAOUT=1 Q
S $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",22)=+Y
I '+Y S $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",23)=+$P($G(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6),$P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",24)=DUZ,$P(^(PSALINE),"^",25)=DT
Q
;
REORDER ;Enter reorder level for drug if the field is blank.
W:'$G(PSADU) !,"DISPENSE UNITS: "_$P($G(^PSDRUG(+PSAIEN,660)),"^",8)
S PSADU=1,DIR(0)="NO^0:99999",DIR("A")="REORDER LEVEL IN "_$P($G(^PSD(58.8,PSALOC,0)),"^")
S DIR("?")="Enter the minimum number of dispense units to keep in the "_$S($P(PSADATA,"^",19)="CS":"master vault.",1:"pharmacy location."),DIR("??")="^D REORD^PSAPROC8"
S DIR("B")=$S(+$P(PSADATA,"^",21):+$P(PSADATA,"^",21),+$P($G(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",5):$P(^PSD(58.8,PSALOC,1,PSAIEN,0),"^",5),1:"")
D ^DIR K DIR I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q
S $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",21)=+Y
Q
;
STOCK ;Enter stock level for drug if the field is blank.
W:'$G(PSADU) !,"DISPENSE UNITS: "_$P($G(^PSDRUG(+PSAIEN,660)),"^",8)
S PSADU=1,DIR(0)="NO^0:99999",DIR("A")="STOCK LEVEL IN "_$P($G(^PSD(58.8,+PSALOC,0)),"^")
S DIR("?")="Enter the minimum number of dispense units to keep on the shelf",DIR("??")="^D STKLEVEL^PSAPROC8"
S DIR("B")=$S(+$P(PSADATA,"^",27):+$P(PSADATA,"^",27),+$P($G(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",3):$P(^PSD(58.8,PSALOC,1,PSAIEN,0),"^",3),1:"")
D ^DIR K DIR I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q
Q:$G(DIRUT)
S:+Y $P(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",27)=+Y
Q
;
DISPYN ;Extended help to enter dispense units
W !?5,"Enter Yes if you want to enter the dispense units now.",!!?5,"Enter No to bypass entering the dispense units. The invoice will not",!?5,"be placed in a Processed status if the dispense units are not entered."
Q
DUOUYN ;Extended help to enter dispense units per order units
W !?5,"Enter Yes if you want to enter the dispense units per order unit now.",!!?5,"Enter No to bypass entering the dispense units per order unit. The"
W !?5,"invoice will not be placed in a "_$S($D(PSABEFOR):"Verified",1:"Processed")_" status if the dispense units",!?5,"are not entered."
Q
PRICEOU ;Extended help to 'Is invoice's price per order unit correct'
W !?5,"Enter Yes if the invoice's price per order unit is correct. The",!?5,"invoice's price per order unit will be entered into the DRUG file."
W !!?5,"Enter No if the invoice's price per order unit is not correct.",!?5,"The DRUG file's price per order unit will remain the same."
Q
REORD ;Extended help for 'Reorder level'
W !?5,"Enter the lowest amount of "_$P($G(^PSDRUG(PSAIEN,660)),"^",8)_"s to keep in the "_$S($P(PSADATA,"^",19)="CS":"master vault",1:"pharmacy location")_"."
W !!?5,"When the amount on hand is lower than the reorder level, a mail",!?5,"message will be sent showing the drug name, reorder level, and",!?5,"quantity on hand."
Q
STKLEVEL ;Extended help for 'Stock level'
W !?5,"Enter the ideal number of dispense units to keep on the shelf. When the",!?5,"number of dispense units is equal to or less than the reorder level, the"
W !?5,"amount to order is determined by subtracting the current number of dispense",!?5,"units from the stock level."
Q
PSAPROC8 ;BIR/JMB-Process Uploaded Prime Vendor Invoice Data - CONT'D ;7/23/97
+1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**3**; 10/24/97
+2 ;This routine processes uploaded invoices.
+3 ;
DU ;Prompts Dispense Unit if blank
+1 FOR
LOCK +^PSDRUG(PSAIEN,0):0
IF $TEST
QUIT
+2 SET DIE="^PSDRUG("
SET DA=PSAIEN
SET DR=14.5
DO ^DIE
KILL DIE
LOCK -^PSDRUG(PSAIEN,0)
+3 IF +$PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)
Begin DoDot:1
+4 FOR
LOCK +^PSDRUG(PSAIEN,0):0
IF $TEST
QUIT
+5 SET DIE="^PSDRUG("
SET DA=PSAIEN
SET DR="14.5///@"
DO ^DIE
KILL DIE
LOCK -^PSDRUG(PSAIEN,0)
End DoDot:1
GOTO DU
+6 IF $PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)'=""
SET PSADU=1
QUIT
+7 ;
+8 WRITE !,"The dispense units must be entered to change",!,"the status of the invoice to Processed."
+9 SET DIR(0)="Y"
SET DIR("B")="Y"
SET DIR("A")="Do you want to enter the dispense units now"
SET DIR("?",1)="Enter Yes to return to the DISPENSE UNIT prompt."
SET DIR("?")="Enter No to bypass entering the dispense units now."
+10 SET DIR("??")="^D DISPYN^PSAPROC8"
DO ^DIR
KILL DIR
IF $GET(DIRUT)
SET PSAOUT=1
QUIT
+11 IF +Y
GOTO DU
+12 QUIT
+13 ;
DUOU ;Gets Dispense Units per Order Unit
+1 IF '$GET(PSADU)
WRITE !,"DISPENSE UNITS: "_$PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)
+2 SET PSADU=1
+3 FOR
LOCK +^PSDRUG(PSAIEN,0):0
IF $TEST
QUIT
+4 SET DIE="^PSDRUG("_PSAIEN_",1,"
SET DA(1)=PSAIEN
SET DA=+PSASUB
SET DR=403
DO ^DIE
KILL DIE
LOCK -^PSDRUG(PSAIEN,0)
+5 IF $DATA(Y)!($GET(DTOUT))
SET PSAOUT=1
QUIT
+6 IF +$PIECE($GET(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",7)
QUIT
+7 ;
+8 SET DIR(0)="Y"
SET DIR("B")="Y"
SET DIR("A",1)="The dispense units per order unit must be entered to change the "
SET DIR("A")="status of the invoice to Processed. Do you want to enter the data now"
+9 SET DIR("?",1)="Enter Yes to return to the "_$PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)_"s per "_$PIECE($GET(^DIC(51.5,+$PIECE($PIECE(PSADATA,"^",2),"~",2),0)),"^",2)_" prompt."
+10 SET DIR("?")="Enter No to bypass entering the dispense units now."
SET DIR("??")="^D DUOUYN^PSAPROC8"
+11 DO ^DIR
KILL DIR
IF $GET(DTOUT)!($GET(DUOUT))
SET PSAOUT=1
QUIT
+12 IF +Y
GOTO DUOU
+13 QUIT
OK ;
+1 SET PSACNTOK=PSACNTOK+1
SET PSAOK(PSACNTOK)=$PIECE(^XTMP("PSAPV",PSACTRL,"IN"),"^",4)_"^"_$PIECE(^("IN"),"^",2)_"^"_PSACTRL_"^"_$PIECE(^("IN"),"^",7)
+2 QUIT
PRICE ;Price per Order Unit changed
+1 SET PSAIPR=$LENGTH($FNUMBER($PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",3),",",2))
SET PSAFPR=$LENGTH($FNUMBER($PIECE($GET(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6),",",2))
+2 SET PSAJUST=$SELECT(PSAIPR>PSAFPR:PSAIPR,1:PSAFPR)
+3 WRITE !!,"Price per Order Unit -- Invoice's: $"_$JUSTIFY($FNUMBER($PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",3),",",2),PSAJUST,2),!?24,"File's : $"_$JUSTIFY($FNUMBER($PIECE($GET(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6),",",2),PSAJUST,2),!
+4 SET DIR(0)="Y"
SET DIR("A")="Is the invoice's price per order unit correct"
SET DIR("B")="Y"
SET DIR("?",1)="Enter Yes if "_$PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",3)_" is correct."
+5 SET DIR("?")="Enter No to keep the file's price per order unit."
SET DIR("??")="^D PRICEOU^PSAPROC1"
DO ^DIR
KILL DIR
IF $GET(DIRUT)
SET PSAOUT=1
QUIT
+6 SET $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",22)=+Y
+7 IF '+Y
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",23)=+$PIECE($GET(^PSDRUG(PSAIEN,1,PSASUB,0)),"^",6)
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",24)=DUZ
SET $PIECE(^(PSALINE),"^",25)=DT
+8 QUIT
+9 ;
REORDER ;Enter reorder level for drug if the field is blank.
+1 IF '$GET(PSADU)
WRITE !,"DISPENSE UNITS: "_$PIECE($GET(^PSDRUG(+PSAIEN,660)),"^",8)
+2 SET PSADU=1
SET DIR(0)="NO^0:99999"
SET DIR("A")="REORDER LEVEL IN "_$PIECE($GET(^PSD(58.8,PSALOC,0)),"^")
+3 SET DIR("?")="Enter the minimum number of dispense units to keep in the "_$SELECT($PIECE(PSADATA,"^",19)="CS":"master vault.",1:"pharmacy location.")
SET DIR("??")="^D REORD^PSAPROC8"
+4 SET DIR("B")=$SELECT(+$PIECE(PSADATA,"^",21):+$PIECE(PSADATA,"^",21),+$PIECE($GET(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",5):$PIECE(^PSD(58.8,PSALOC,1,PSAIEN,0),"^",5),1:"")
+5 DO ^DIR
KILL DIR
IF $GET(DTOUT)!($GET(DUOUT))
SET PSAOUT=1
QUIT
+6 SET $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",21)=+Y
+7 QUIT
+8 ;
STOCK ;Enter stock level for drug if the field is blank.
+1 IF '$GET(PSADU)
WRITE !,"DISPENSE UNITS: "_$PIECE($GET(^PSDRUG(+PSAIEN,660)),"^",8)
+2 SET PSADU=1
SET DIR(0)="NO^0:99999"
SET DIR("A")="STOCK LEVEL IN "_$PIECE($GET(^PSD(58.8,+PSALOC,0)),"^")
+3 SET DIR("?")="Enter the minimum number of dispense units to keep on the shelf"
SET DIR("??")="^D STKLEVEL^PSAPROC8"
+4 SET DIR("B")=$SELECT(+$PIECE(PSADATA,"^",27):+$PIECE(PSADATA,"^",27),+$PIECE($GET(^PSD(58.8,PSALOC,1,PSAIEN,0)),"^",3):$PIECE(^PSD(58.8,PSALOC,1,PSAIEN,0),"^",3),1:"")
+5 DO ^DIR
KILL DIR
IF $GET(DTOUT)!($GET(DUOUT))
SET PSAOUT=1
QUIT
+6 IF $GET(DIRUT)
QUIT
+7 IF +Y
SET $PIECE(^XTMP("PSAPV",PSACTRL,"IT",PSALINE),"^",27)=+Y
+8 QUIT
+9 ;
DISPYN ;Extended help to enter dispense units
+1 WRITE !?5,"Enter Yes if you want to enter the dispense units now.",!!?5,"Enter No to bypass entering the dispense units. The invoice will not",!?5,"be placed in a Processed status if the dispense units are not entered."
+2 QUIT
DUOUYN ;Extended help to enter dispense units per order units
+1 WRITE !?5,"Enter Yes if you want to enter the dispense units per order unit now.",!!?5,"Enter No to bypass entering the dispense units per order unit. The"
+2 WRITE !?5,"invoice will not be placed in a "_$SELECT($DATA(PSABEFOR):"Verified",1:"Processed")_" status if the dispense units",!?5,"are not entered."
+3 QUIT
PRICEOU ;Extended help to 'Is invoice's price per order unit correct'
+1 WRITE !?5,"Enter Yes if the invoice's price per order unit is correct. The",!?5,"invoice's price per order unit will be entered into the DRUG file."
+2 WRITE !!?5,"Enter No if the invoice's price per order unit is not correct.",!?5,"The DRUG file's price per order unit will remain the same."
+3 QUIT
REORD ;Extended help for 'Reorder level'
+1 WRITE !?5,"Enter the lowest amount of "_$PIECE($GET(^PSDRUG(PSAIEN,660)),"^",8)_"s to keep in the "_$SELECT($PIECE(PSADATA,"^",19)="CS":"master vault",1:"pharmacy location")_"."
+2 WRITE !!?5,"When the amount on hand is lower than the reorder level, a mail",!?5,"message will be sent showing the drug name, reorder level, and",!?5,"quantity on hand."
+3 QUIT
STKLEVEL ;Extended help for 'Stock level'
+1 WRITE !?5,"Enter the ideal number of dispense units to keep on the shelf. When the",!?5,"number of dispense units is equal to or less than the reorder level, the"
+2 WRITE !?5,"amount to order is determined by subtracting the current number of dispense",!?5,"units from the stock level."
+3 QUIT