- PSDREC4 ;BIR/LTL-Issues Receiving ; 8 Aug 94
- ;;3.0; CONTROLLED SUBSTANCES ;**30,66**;13 Feb 97;Build 3
- ;Reference to ^PRC(441 supported by IA #682
- ;References to $$UNITCODE^PRCPUX1 are covered by IA #259
- ;Reference to ^PRCS(410 supported by IA #214
- ;Reference to ^PSD(58.8 are covered by DBIA #2711
- ;Reference to ^PSD(58.81 are covered by DBIA #2808
- ;References to ^PSDRUG( are covered by IA #221
- PRE I $O(^PSD(58.81,"E",+PSDCON,"")) W !!,"Previous receipts have been processed for this transaction.",! S DIR(0)="Y",DIR("A")="Would you like to review them before proceeding",DIR("B")="Yes" D ^DIR K DIR G:$D(DIRUT) QUIT G:Y=1 DEV^PSDREVC
- CHO S PSDI=0,DIR(0)="Y",DIR("A")="Loop through all items",DIR("B")="Yes",DIR("?")="If not, I will ask you to select the item(s) to receive." W ! D ^DIR K DIR G:$D(DIRUT) QUIT G:'Y SEL
- F S PSDI=$O(^PRCS(410,+PSDCON,"IT",PSDI)) G:'PSDI!($D(DTOUT))!($D(DUOUT)) QUIT S PSDIT=$G(^PRCS(410,+PSDCON,"IT",PSDI,0)) D ITEM G:$D(DTOUT)!($D(DUOUT))!($D(Y)) QUIT
- SEL F S DIC="^PRCS(410,+PSDCON,""IT"",",DIC(0)="AEMQZ",DA(1)=PSDCON D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT))!(Y<1) QUIT S PSDI=+Y,PSDIT=Y(0) D ITEM G:$D(DTOUT)!($D(DUOUT)) QUIT
- ITEM W !!,$P(PSDIT,U)
- S PSDW=0 F S PSDW=$O(^PRCS(410,+PSDCON,"IT",+PSDI,1,PSDW)) Q:'PSDW W ?5,$E($P($G(^PRCS(410,+PSDCON,"IT",+PSDI,1,PSDW,0)),U),1,75),!
- W !,"Packaging: "
- W $$UNITCODE^PRCPUX1(+$P(PSDIT,U,3))
- W ?18,"Price :$",$P(PSDIT,U,7)
- W ?33,"Item #: ",$P(PSDIT,U,5),?48,"Vendor Stock #: ",$P(PSDIT,U,6),!
- NON I $S('$P(PSDIT,U,5):1,'$O(^PSDRUG("AB",+$P(PSDIT,U,5),"")):1,'$O(^PSD(58.8,PSDLOC,1,$O(^PSDRUG("AB",+$P(PSDIT,U,5),"")),""))=0:1,1:0) D Q:$D(DTOUT)!($D(DUOUT))!(Y<1)
- .S DIC="^PSD(58.8,PSDLOC,1,",DIC(0)="AEMQZ",DIC("A")="Select "_PSDLOCN_" drug: ",DIC("S")="I $S($P($G(^(0)),U,14):$P($G(^(0)),U,14)>DT,1:1)",DA(1)=PSDLOC D ^DIC K DIC Q:$D(DTOUT)!($D(DUOUT))!(Y<1)
- .S PSDRUG=+Y,PSDRUGN=$P($G(^PSDRUG(+Y,0)),U),PSDB=$P($G(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)),U,4)
- .I $P(PSDIT,U,5),$E($G(^PRC(441,+$P(PSDIT,U,5),3)),1)'=1,'$O(^PSDRUG("AB",+$P(PSDIT,U,5),"")) D
- ..S DIR(0)="Y",DIR("A",1)="Are you sure that you want to link ITEM MASTER file entry,"
- ..S DIR("A",2)="",DIR("A",3)=$P($G(^PRC(441,+$P(PSDIT,U,5),0)),U,2)_" to DRUG file entry,"
- ..S DIR("A",4)="",DIR("A",5)=PSDRUGN,DIR("A")="Y/N",DIR("B")="Yes"
- ..S DIR("?")="Onced linked, future receipts for this item will be posted to this drug.",DIR("A",6)=""
- ..W ! D ^DIR K DIR Q:Y<1
- ..S DIE=50,DA=PSDRUG,DR="441///^S X=$P(PSDIT,U,5)" D ^DIE K DIE W:'$D(Y) !!,"Now, ",PSDRUGN," is linked to Item # ",$P(PSDIT,U,5),"." S Y=1
- IT S:'$D(PSDRUG) PSDRUG=$O(^PSDRUG("AB",+$P(PSDIT,U,5),"")),PSDRUGN=$P($G(^PSDRUG(+PSDRUG,0)),U)
- W !!,PSDRUGN,!!
- S DIE="^PSDRUG(",DA=PSDRUG,DR="15Dispense units per order unit;13Price per order unit" D ^DIE K DIE I $D(Y) K PSDRUG Q
- DISP W !!,"Quantity ordered: ",$P($G(^PRCS(410,+PSDCON,"IT",+PSDI,0)),U,2) S PSDREC=$P($G(^(0)),U,2)
- I $P($G(^PRCS(410,+PSDCON,"IT",+PSDI,0)),U,12) W ?40,"Quantity warehouse posted: ",$P($G(^(0)),U,12) S PSDREC=$P($G(^(0)),U,12)
- I $P($G(^PRCS(410,+PSDCON,"IT",+PSDI,0)),U,13) W !!,"Quantity received by Primary: ",$P($G(^(0)),U,13) S PSDREC=$P($G(^(0)),U,13)
- W ?40,"Converted quantity: ",PSDREC*$P($G(^PSDRUG(+PSDRUG,660)),U,5),! S PSDREC=$P($G(^(660)),U,5)*PSDREC
- ;PSD*3*29 (Dave B) Check to see if drug actually stocked
- I '$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)) W !,"Sorry, but this drug is not stocked in this pharmacy location.",! Q
- POST S DIR(0)="Y",DIR("A")="OK to post",DIR("B")="Yes",DIR("?")="If yes, the balance will be updated and a transaction stored." D ^DIR K DIR D:Y=1 K PSDRUG Q
- .W !!,"There were ",$S($P($G(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)),U,4):$P($G(^(0)),U,4),1:0)," on hand.",?40,"There are now ",$P($G(^(0)),U,4)+PSDREC," on hand.",!
- .F L +^PSD(58.8,+PSDLOC,1,+PSDRUG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
- .D NOW^%DTC S PSDAT=+%
- .S PSDB=$P($G(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)),U,4)
- .S $P(^PSD(58.8,+PSDLOC,1,+PSDRUG,0),U,4)=PSDREC+PSDB
- .L -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
- MON .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,0)) ^(0)="^58.801A^^"
- .I '$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,$E(DT,1,5)*100,0)) S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,",DIC(0)="",X=$E(DT,1,5)*100,DA(2)=PSDLOC,DA(1)=PSDRUG D ^DIC K DIC
- .S DIE="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,",DA(2)=PSDLOC,DA(1)=PSDRUG,DA=$E(DT,1,5)*100,DR="5////^S X=$P($G(^(0)),U,3)+PSDREC" D ^DIE
- .W !,"Updating monthly receipts and transaction history.",!
- TR .F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
- FIND .S PSDT=$P(^PSD(58.81,0),U,3)+1 I $D(^PSD(58.81,PSDT)) S $P(^PSD(58.81,0),U,3)=$P(^PSD(58.81,0),U,3)+1 G FIND
- .S DIC="^PSD(58.81,",DIC(0)="L",DLAYGO=58.81,(DINUM,X)=PSDT D ^DIC K DIC,DLAYGO L -^PSD(58.81,0)
- .S DIE="^PSD(58.81,",DA=PSDT,DR="1////1;2////^S X=PSDLOC;3////^S X=PSDAT;4////^S X=PSDRUG;5////^S X=PSDREC;6////^S X=DUZ;7////^S X=PSDCON;8////^S X=PSDPO;9////^S X=PSDB;100////1" D ^DIE K DIE
- .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,4,0)) ^(0)="^58.800119PA^^"
- .S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,4,",DIC(0)="L",DLAYGO=58.8
- .S (X,DINUM)=PSDT,DA(2)=PSDLOC,DA(1)=PSDRUG
- .D ^DIC K DIC,DA,DLAYGO,PSDRUG
- QUIT Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDREC4 5153 printed Feb 18, 2025@23:14:51 Page 2
- PSDREC4 ;BIR/LTL-Issues Receiving ; 8 Aug 94
- +1 ;;3.0; CONTROLLED SUBSTANCES ;**30,66**;13 Feb 97;Build 3
- +2 ;Reference to ^PRC(441 supported by IA #682
- +3 ;References to $$UNITCODE^PRCPUX1 are covered by IA #259
- +4 ;Reference to ^PRCS(410 supported by IA #214
- +5 ;Reference to ^PSD(58.8 are covered by DBIA #2711
- +6 ;Reference to ^PSD(58.81 are covered by DBIA #2808
- +7 ;References to ^PSDRUG( are covered by IA #221
- PRE IF $ORDER(^PSD(58.81,"E",+PSDCON,""))
- WRITE !!,"Previous receipts have been processed for this transaction.",!
- SET DIR(0)="Y"
- SET DIR("A")="Would you like to review them before proceeding"
- SET DIR("B")="Yes"
- DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO QUIT
- if Y=1
- GOTO DEV^PSDREVC
- CHO SET PSDI=0
- SET DIR(0)="Y"
- SET DIR("A")="Loop through all items"
- SET DIR("B")="Yes"
- SET DIR("?")="If not, I will ask you to select the item(s) to receive."
- WRITE !
- DO ^DIR
- KILL DIR
- if $DATA(DIRUT)
- GOTO QUIT
- if 'Y
- GOTO SEL
- +1 FOR
- SET PSDI=$ORDER(^PRCS(410,+PSDCON,"IT",PSDI))
- if 'PSDI!($DATA(DTOUT))!($DATA(DUOUT))
- GOTO QUIT
- SET PSDIT=$GET(^PRCS(410,+PSDCON,"IT",PSDI,0))
- DO ITEM
- if $DATA(DTOUT)!($DATA(DUOUT))!($DATA(Y))
- GOTO QUIT
- SEL FOR
- SET DIC="^PRCS(410,+PSDCON,""IT"","
- SET DIC(0)="AEMQZ"
- SET DA(1)=PSDCON
- DO ^DIC
- KILL DIC
- if $DATA(DTOUT)!($DATA(DUOUT))!(Y<1)
- GOTO QUIT
- SET PSDI=+Y
- SET PSDIT=Y(0)
- DO ITEM
- if $DATA(DTOUT)!($DATA(DUOUT))
- GOTO QUIT
- ITEM WRITE !!,$PIECE(PSDIT,U)
- +1 SET PSDW=0
- FOR
- SET PSDW=$ORDER(^PRCS(410,+PSDCON,"IT",+PSDI,1,PSDW))
- if 'PSDW
- QUIT
- WRITE ?5,$EXTRACT($PIECE($GET(^PRCS(410,+PSDCON,"IT",+PSDI,1,PSDW,0)),U),1,75),!
- +2 WRITE !,"Packaging: "
- +3 WRITE $$UNITCODE^PRCPUX1(+$PIECE(PSDIT,U,3))
- +4 WRITE ?18,"Price :$",$PIECE(PSDIT,U,7)
- +5 WRITE ?33,"Item #: ",$PIECE(PSDIT,U,5),?48,"Vendor Stock #: ",$PIECE(PSDIT,U,6),!
- NON IF $SELECT('$PIECE(PSDIT,U,5):1,'$ORDER(^PSDRUG("AB",+$PIECE(PSDIT,U,5),"")):1,'$ORDER(^PSD(58.8,PSDLOC,1,$ORDER(^PSDRUG("AB",+$PIECE(PSDIT,U,5),"")),""))=0:1,1:0)
- Begin DoDot:1
- +1 SET DIC="^PSD(58.8,PSDLOC,1,"
- SET DIC(0)="AEMQZ"
- SET DIC("A")="Select "_PSDLOCN_" drug: "
- SET DIC("S")="I $S($P($G(^(0)),U,14):$P($G(^(0)),U,14)>DT,1:1)"
- SET DA(1)=PSDLOC
- DO ^DIC
- KILL DIC
- if $DATA(DTOUT)!($DATA(DUOUT))!(Y<1)
- QUIT
- +2 SET PSDRUG=+Y
- SET PSDRUGN=$PIECE($GET(^PSDRUG(+Y,0)),U)
- SET PSDB=$PIECE($GET(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)),U,4)
- +3 IF $PIECE(PSDIT,U,5)
- IF $EXTRACT($GET(^PRC(441,+$PIECE(PSDIT,U,5),3)),1)'=1
- IF '$ORDER(^PSDRUG("AB",+$PIECE(PSDIT,U,5),""))
- Begin DoDot:2
- +4 SET DIR(0)="Y"
- SET DIR("A",1)="Are you sure that you want to link ITEM MASTER file entry,"
- +5 SET DIR("A",2)=""
- SET DIR("A",3)=$PIECE($GET(^PRC(441,+$PIECE(PSDIT,U,5),0)),U,2)_" to DRUG file entry,"
- +6 SET DIR("A",4)=""
- SET DIR("A",5)=PSDRUGN
- SET DIR("A")="Y/N"
- SET DIR("B")="Yes"
- +7 SET DIR("?")="Onced linked, future receipts for this item will be posted to this drug."
- SET DIR("A",6)=""
- +8 WRITE !
- DO ^DIR
- KILL DIR
- if Y<1
- QUIT
- +9 SET DIE=50
- SET DA=PSDRUG
- SET DR="441///^S X=$P(PSDIT,U,5)"
- DO ^DIE
- KILL DIE
- if '$DATA(Y)
- WRITE !!,"Now, ",PSDRUGN," is linked to Item # ",$PIECE(PSDIT,U,5),"."
- SET Y=1
- End DoDot:2
- End DoDot:1
- if $DATA(DTOUT)!($DATA(DUOUT))!(Y<1)
- QUIT
- IT if '$DATA(PSDRUG)
- SET PSDRUG=$ORDER(^PSDRUG("AB",+$PIECE(PSDIT,U,5),""))
- SET PSDRUGN=$PIECE($GET(^PSDRUG(+PSDRUG,0)),U)
- +1 WRITE !!,PSDRUGN,!!
- +2 SET DIE="^PSDRUG("
- SET DA=PSDRUG
- SET DR="15Dispense units per order unit;13Price per order unit"
- DO ^DIE
- KILL DIE
- IF $DATA(Y)
- KILL PSDRUG
- QUIT
- DISP WRITE !!,"Quantity ordered: ",$PIECE($GET(^PRCS(410,+PSDCON,"IT",+PSDI,0)),U,2)
- SET PSDREC=$PIECE($GET(^(0)),U,2)
- +1 IF $PIECE($GET(^PRCS(410,+PSDCON,"IT",+PSDI,0)),U,12)
- WRITE ?40,"Quantity warehouse posted: ",$PIECE($GET(^(0)),U,12)
- SET PSDREC=$PIECE($GET(^(0)),U,12)
- +2 IF $PIECE($GET(^PRCS(410,+PSDCON,"IT",+PSDI,0)),U,13)
- WRITE !!,"Quantity received by Primary: ",$PIECE($GET(^(0)),U,13)
- SET PSDREC=$PIECE($GET(^(0)),U,13)
- +3 WRITE ?40,"Converted quantity: ",PSDREC*$PIECE($GET(^PSDRUG(+PSDRUG,660)),U,5),!
- SET PSDREC=$PIECE($GET(^(660)),U,5)*PSDREC
- +4 ;PSD*3*29 (Dave B) Check to see if drug actually stocked
- +5 IF '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,0))
- WRITE !,"Sorry, but this drug is not stocked in this pharmacy location.",!
- QUIT
- POST SET DIR(0)="Y"
- SET DIR("A")="OK to post"
- SET DIR("B")="Yes"
- SET DIR("?")="If yes, the balance will be updated and a transaction stored."
- DO ^DIR
- KILL DIR
- if Y=1
- Begin DoDot:1
- +1 WRITE !!,"There were ",$SELECT($PIECE($GET(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)),U,4):$PIECE($GET(^(0)),U,4),1:0)," on hand.",?40,"There are now ",$PIECE($GET(^(0)),U,4)+PSDREC," on hand.",!
- +2 FOR
- LOCK +^PSD(58.8,+PSDLOC,1,+PSDRUG,0):$SELECT($GET(DILOCKTM)>0:DILOCKTM,1:3)
- IF $TEST
- QUIT
- +3 DO NOW^%DTC
- SET PSDAT=+%
- +4 SET PSDB=$PIECE($GET(^PSD(58.8,+PSDLOC,1,+PSDRUG,0)),U,4)
- +5 SET $PIECE(^PSD(58.8,+PSDLOC,1,+PSDRUG,0),U,4)=PSDREC+PSDB
- +6 LOCK -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
- MON if '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,0))
- SET ^(0)="^58.801A^^"
- +1 IF '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,$EXTRACT(DT,1,5)*100,0))
- SET DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,"
- SET DIC(0)=""
- SET X=$EXTRACT(DT,1,5)*100
- SET DA(2)=PSDLOC
- SET DA(1)=PSDRUG
- DO ^DIC
- KILL DIC
- +2 SET DIE="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,"
- SET DA(2)=PSDLOC
- SET DA(1)=PSDRUG
- SET DA=$EXTRACT(DT,1,5)*100
- SET DR="5////^S X=$P($G(^(0)),U,3)+PSDREC"
- DO ^DIE
- +3 WRITE !,"Updating monthly receipts and transaction history.",!
- TR FOR
- LOCK +^PSD(58.81,0):$SELECT($GET(DILOCKTM)>0:DILOCKTM,1:3)
- IF $TEST
- QUIT
- FIND SET PSDT=$PIECE(^PSD(58.81,0),U,3)+1
- IF $DATA(^PSD(58.81,PSDT))
- SET $PIECE(^PSD(58.81,0),U,3)=$PIECE(^PSD(58.81,0),U,3)+1
- GOTO FIND
- +1 SET DIC="^PSD(58.81,"
- SET DIC(0)="L"
- SET DLAYGO=58.81
- SET (DINUM,X)=PSDT
- DO ^DIC
- KILL DIC,DLAYGO
- LOCK -^PSD(58.81,0)
- +2 SET DIE="^PSD(58.81,"
- SET DA=PSDT
- SET DR="1////1;2////^S X=PSDLOC;3////^S X=PSDAT;4////^S X=PSDRUG;5////^S X=PSDREC;6////^S X=DUZ;7////^S X=PSDCON;8////^S X=PSDPO;9////^S X=PSDB;100////1"
- DO ^DIE
- KILL DIE
- +3 if '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,4,0))
- SET ^(0)="^58.800119PA^^"
- +4 SET DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,4,"
- SET DIC(0)="L"
- SET DLAYGO=58.8
- +5 SET (X,DINUM)=PSDT
- SET DA(2)=PSDLOC
- SET DA(1)=PSDRUG
- +6 DO ^DIC
- KILL DIC,DA,DLAYGO,PSDRUG
- End DoDot:1
- KILL PSDRUG
- QUIT
- QUIT QUIT