[613] | 1 | PSDOPT0 ;BIR/JPW,LTL,BJW - Outpatient Rx Entry (cont'd) ; 22 Jun 98
|
---|
| 2 | ;;3.0; CONTROLLED SUBSTANCES ;**10,30,37,39,45,48,66**;13 Feb 97;Build 3
|
---|
| 3 | ;Reference to PS(52.5 supported by DBIA #786
|
---|
| 4 | ;Reference to PS(59.7 supported by DBIA #1930
|
---|
| 5 | ;References to ^PSD(58.8 are covered by DBIA #2711
|
---|
| 6 | ;References to file 58.81 are covered by DBIA #2808
|
---|
| 7 | ;Reference to ^PSDRUG( supported by DBIA #221
|
---|
| 8 | ;Reference to PSRX( supported by DBIA #986
|
---|
| 9 | ;called by ^PSDOPT,mod.for nois#:tua-0498-32173
|
---|
| 10 | ;08/02/2004 KAM PSD*3*45 Modification to stop posting of the same
|
---|
| 11 | ; partial multiple times
|
---|
| 12 | LOOP ;loop to find new, refills and partials
|
---|
| 13 | W !!,"Accessing the prescription history..."
|
---|
| 14 | N PSDOIN,PSDRXFD,PSDSUPN,PSDLBL S PSDOIN=+$P($G(^PS(59.7,1,49.99)),U,2)
|
---|
| 15 | ;check for unposted refills not returned to stock and not in suspense
|
---|
| 16 | S (RF,DAT)=0 F JJ=0:0 S JJ=$O(^PSRX(PSDRX,1,JJ)) Q:'JJ I $D(^PSRX(PSDRX,1,JJ,0)),'$P(^(0),U,16),$P($G(^(0)),U)'<PSDOIN D
|
---|
| 17 | .;checking for suspense
|
---|
| 18 | .S PSDRXFD=$E($P(^PSRX(PSDRX,1,JJ,0),U),1,7)
|
---|
| 19 | .S PSDSUPN=$O(^PS(52.5,"B",PSDRX,0))
|
---|
| 20 | .I PSDSUPN,$D(^PS(52.5,"C",PSDRXFD,PSDSUPN)),$G(^PS(52.5,PSDSUPN,"P"))'=1 W !!,"Refill #",JJ," suspended." Q
|
---|
| 21 | .S RXNUM("RF",JJ)=+^PSRX(PSDRX,1,JJ,0)_U_$P(^(0),U,4),$P(PSDSEL("RF",JJ),"^",1)=$P(RXNUM("RF",JJ),"^",1),$P(PSDSEL("RF",JJ),"^",2)=$P(RXNUM("RF",JJ),"^",2),$P(PSDSEL("RF",JJ),"^",3)=$P($G(PSDRX("RF",JJ)),"^",3) K PSDLBLP
|
---|
| 22 | ;
|
---|
| 23 | ;check for unposted partials not returned to stock or suspended
|
---|
| 24 | ;
|
---|
| 25 | S PRF=0 F JJ=0:0 S JJ=$O(^PSRX(PSDRX,"P",JJ)) Q:'JJ I $D(^PSRX(PSDRX,"P",JJ,0)),'$P(^(0),U,16),$P($G(^(0)),U)'<PSDOIN D
|
---|
| 26 | .;check for suspense
|
---|
| 27 | .S PSDRXFD=$E($P(^PSRX(PSDRX,"P",JJ,0),U),1,7)
|
---|
| 28 | .S PSDSUPN=$O(^PS(52.5,"B",PSDRX,0))
|
---|
| 29 | .I PSDSUPN,$D(^PS(52.5,"C",PSDRXFD,PSDSUPN)),$G(^PS(52.5,PSDSUPN,"P"))'=1,($G(JJ)=$P(^PS(52.5,PSDSUPN,0),U,5)) W !!,"Partial #",JJ," suspended." Q
|
---|
| 30 | .S RXNUM("PR",JJ)=+^PSRX(PSDRX,"P",JJ,0)_U_$P(^(0),U,4),$P(PSDSEL("PR",JJ),"^",1)=$P(RXNUM("PR",JJ),"^",1),$P(PSDSEL("PR",JJ),"^",2)=$P(RXNUM("PR",JJ),"^",2) K PSDLBL
|
---|
| 31 | ;
|
---|
| 32 | ;original returned to stock
|
---|
| 33 | ;
|
---|
| 34 | S:$P($G(^PSRX(+PSDRX,2)),U,15) PSDRX(1)=""
|
---|
| 35 | ;Check for suspense
|
---|
| 36 | I +$P($G(^PSRX(PSDRX,2)),U,2)'<PSDOIN S PSDRXFD=$P(^(2),U,2) D
|
---|
| 37 | .S PSDSUPN=$O(^PS(52.5,"B",PSDRX,0))
|
---|
| 38 | .I PSDSUPN,$D(^PS(52.5,"C",PSDRXFD,PSDSUPN)),$G(^PS(52.5,PSDSUPN,"P"))'=1 W !!,"Original suspended." S PSDRX(1)="" Q
|
---|
| 39 | PSDDAVE ;PSD*3*30 (Major overhaul, Dave B)
|
---|
| 40 | ;PSDSEL("RF",#)=refill Date ^ QTY ^ posted (y/n) ^ released date
|
---|
| 41 | ;PSDSEL("PR" ''
|
---|
| 42 | ;PSDSEL("OR" same thing
|
---|
| 43 | ;
|
---|
| 44 | I '$D(PSDRX(1)) S $P(PSDSEL("OR"),"^",2)=$P(^PSRX(+PSDRX,0),"^",7) ;Quantity
|
---|
| 45 | I $D(PSDRX("OR")) S $P(PSDSEL("OR"),"^",3)=1 ;Posted
|
---|
| 46 | I $P($G(^PSRX(+PSDRX,2)),"^",13)'="" S Y=$P(^PSRX(+PSDRX,2),"^",13) X ^DD("DD") S $P(PSDSEL("OR"),"^",4)=Y ;released date
|
---|
| 47 | I $D(PSDSEL("OR")),$P(PSDSEL("OR"),"^",3)'="",$P(PSDSEL("OR"),"^",4)'="" K PSDSEL("OR"),RXNUM("OR")
|
---|
| 48 | S (PSDRF1,PSDPR1)=0
|
---|
| 49 | RFLCHK ;
|
---|
| 50 | S PSDRF1=$O(PSDSEL("RF",PSDRF1)) G PRTLCHK:PSDRF1'>0 S DATA=PSDSEL("RF",PSDRF1)
|
---|
| 51 | I $P($G(^PSRX(+PSDRX,1,PSDRF1,0)),"^",18)'="" S Y=$P(^(0),"^",18) X ^DD("DD") S $P(PSDSEL("RF",PSDRF1),"^",4)=Y ;Already released
|
---|
| 52 | I $P(PSDSEL("RF",PSDRF1),"^",3)>0,$P(PSDSEL("RF",PSDRF1),"^",4)'="" K PSDSEL("RF",PSDRF1),RXNUM("RF",PSDRF1)
|
---|
| 53 | G RFLCHK
|
---|
| 54 | ;
|
---|
| 55 | PRTLCHK S PSDPR1=$O(PSDSEL("PR",PSDPR1)) G CHKALL:PSDPR1'>0
|
---|
| 56 | ; 08/02/2004 PSD*3*45 Added next line
|
---|
| 57 | I $D(PSDRX("PR",PSDPR1)) S $P(PSDSEL("PR",PSDPR1),"^",3)=1 ;Posted
|
---|
| 58 | I $P($G(^PSRX(+PSDRX,"P",PSDPR1,0)),"^",19)'="" S Y=$P(^(0),"^",19) X ^DD("DD") S $P(PSDSEL("PR",PSDPR1),"^",4)=Y
|
---|
| 59 | I $P(PSDSEL("PR",PSDPR1),"^",3)>0,$P(PSDSEL("PR",PSDPR1),"^",4)'="" K PSDSEL("PR",PSDPR1),RXNUM("PR",PSDPR1)
|
---|
| 60 | G PRTLCHK
|
---|
| 61 | ;
|
---|
| 62 | CHKALL ;Check to see if any left to post or release
|
---|
| 63 | I $G(PSDERR)=1 G ASKP^PSDOPT
|
---|
| 64 | I $O(PSDSEL(0))="" W !!,"ALL FILLS FOR THIS PRESCRIPTION HAVE BEEN POSTED AND RELEASED." G ASKP^PSDOPT
|
---|
| 65 | ;
|
---|
| 66 | ;Check for DIR call
|
---|
| 67 | S CNT=0 K DIR
|
---|
| 68 | G CHK^PSDOPT
|
---|
| 69 | ;
|
---|
| 70 | PSDRTS(PSDRX,PSDNUM,PSDSITE,PSDQTY) ; API for Outpatient Pharmacy; Patch PSD*3*30
|
---|
| 71 | ; This subroutine is called each time an Rx is returned to stock
|
---|
| 72 | ; in Outpatient Pharmacy. The code does the following:
|
---|
| 73 | ; 1.Check Rx, quit if not a controlled substance.
|
---|
| 74 | ; 2.Give the user the option to update the transaction and
|
---|
| 75 | ; balance details
|
---|
| 76 | ;PSDCS = 1 is controlled subs/0 for not CS
|
---|
| 77 | ;PSDRS = 1 they have key, ok to return to stock, 0 - no key
|
---|
| 78 | ;Variables:
|
---|
| 79 | ;PSDRX = Prescription Number IEN
|
---|
| 80 | ;PSDNUM = O^0 = The letter O for original fill and the number0
|
---|
| 81 | ; R^# = The letter R for refill and # equal to refill #
|
---|
| 82 | ; P^# = The letter P for partial and # equal to partial #
|
---|
| 83 | ;PSDSITE = Division
|
---|
| 84 | ;PSDQTY = Quantity being returned to stock
|
---|
| 85 | ;
|
---|
| 86 | ;PSD*3*30 Check for PSDMGR key
|
---|
| 87 | S PSDRS=0 I $D(^XUSEC("PSDMGR",DUZ)) S PSDRS=1 ;possess key
|
---|
| 88 | 1 ;begin process
|
---|
| 89 | I $D(^PSD(58.81,"AOP",PSDRX)) D RTSCHK G RETERR:$G(PSDERR)>0
|
---|
| 90 | S PSDOUT=0,RXNUM=$P($G(^PSRX(+PSDRX,0)),"^") ;Prescription Number
|
---|
| 91 | S (RPDT,DAT)=$P($G(^PSRX(+PSDRX,2)),"^",2)
|
---|
| 92 | S DFN=+$P($G(^PSRX(+PSDRX,0)),"^",2)
|
---|
| 93 | S PSDS=$S($G(PSDSITE)["^":$P(PSDSITE,"^",3),1:PSDSITE)
|
---|
| 94 | S PSDR=$P($G(^PSRX(+PSDRX,0)),"^",6) I $G(PSDR)'="" S PSDRN=$P($G(^PSDRUG(PSDR,0)),"^")
|
---|
| 95 | ;Setup like balance adjustment
|
---|
| 96 | S PSDRN=$S($G(PSDRN)="":"Unknown Drug "_PSDR,1:PSDRN)
|
---|
| 97 | I $P($G(^PSDRUG(PSDR,2)),"^",3)'["N" S PSDCS=0 Q
|
---|
| 98 | S PSDCS=1
|
---|
| 99 | I $G(PSDRS)'>0 W !,"Sorry you do not possess the PSDMGR key" G RETERR
|
---|
| 100 | ;
|
---|
| 101 | POSTED ;check to see if posted
|
---|
| 102 | S (JJ,PSDPOST)=0
|
---|
| 103 | F S JJ=$O(^PSD(58.81,"AOP",+PSDRX,JJ)) Q:'JJ I $D(^PSD(58.81,JJ,6)) D
|
---|
| 104 | .S NODE6=$G(^PSD(58.81,JJ,6))
|
---|
| 105 | .I $P(PSDNUM,"^",1)="R",$P(NODE6,"^",2)'="",$P(NODE6,"^",2)=$P(PSDNUM,"^",2) S PSDPOST=1 Q
|
---|
| 106 | .I $P(PSDNUM,"^",1)="P",$P(NODE6,"^",4)'="",$P(NODE6,"^",4)=$P(PSDNUM,"^",2) S PSDPOST=1 Q
|
---|
| 107 | .I $P(PSDNUM,"^",1)="O",$P(NODE6,"^",4)="",$P(NODE6,"^",2)="" S PSDPOST=1 Q
|
---|
| 108 | ;
|
---|
| 109 | ;now check to see if CMOP
|
---|
| 110 | S X1=0 F S X1=$O(^PSRX(+PSDRX,4,X1)) Q:X1="" S DATA=$G(^PSRX(+PSDRX,4,X1,0)) D
|
---|
| 111 | .I $P(PSDNUM,"^",1)="R",$P(DATA,"^",3)=$P(PSDNUM,"^",2) S PSDPOST=1 Q
|
---|
| 112 | .I $P(PSDNUM,"^",1)="P",$P(DATA,"^",3)=$P(PSDNUM,"^",2) S PSDPOST=1 Q
|
---|
| 113 | .I $P(PSDNUM,"^",1)="O",$P(DATA,"^",3)=$P(PSDNUM,"^",2) S PSDPOST=1 Q
|
---|
| 114 | I $G(PSDPOST)'=1 W !!,"Could not find any posting information in the Controlled Substance package,",!,"balance cannot be updated",!
|
---|
| 115 | ;
|
---|
| 116 | ESIG K X D SIG^XUSESIG I X["^" W !,"No signature code entered, RX not returned to stock." S RETSK=1 Q
|
---|
| 117 | I X1="" W !,"An Electronic Signature Code is required to return a Controlled Substance RX to stock.",! G ESIG
|
---|
| 118 | ASK S DIR(0)="Y",DIR("A")="Do you want "_$G(PSDQTY)_" added to balance in the Narcotic vault",DIR("B")="Yes",DIR("?")="Answer Yes and the amount being returned to stock will be placed in inventory" D ^DIR K DIR I $D(DIRUT) G RETERR
|
---|
| 119 | I +Y'>0 W !,"Nothing updated" G RETERR
|
---|
| 120 | LOCATION S DIC(0)="QEA",DIC="^PSD(58.8,",DIC("A")="Return Drug to which vault: "
|
---|
| 121 | S DIC("S")="I ""MSN""[$P($G(^PSD(58.8,Y,0)),U,2)"
|
---|
| 122 | D ^DIC K DIC
|
---|
| 123 | I "MSN"'[$P($G(^PSD(58.8,+Y,0)),"^",2) W !,"Sorry, the location type must be a Master Vault, satellite or narcotic location." K Y G LOCATION
|
---|
| 124 | I +Y'>0 W !,"No selection made, no balance adjusted." G RETERR
|
---|
| 125 | S PSDS=+Y I '$D(^PSD(58.8,+PSDS,1,PSDR,0)) W !,"Sorry, the drug is not stocked in this vault." K PSDS G LOCATION
|
---|
| 126 | S PSDBAL=$P($G(^PSD(58.8,+PSDS,1,PSDR,0)),"^",4) W !,"Previous Balance: ",$G(PSDBAL)_" New Balance: "_($G(PSDBAL)+PSDQTY)
|
---|
| 127 | W !,"Updating balances"
|
---|
| 128 | F L +^PSD(58.8,+PSDS,1,PSDR,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
|
---|
| 129 | D NOW^%DTC S PSDT=+%,BAL=+$P(^PSD(58.8,+PSDS,1,PSDR,0),"^",4),$P(^PSD(58.8,+PSDS,1,PSDR,0),"^",4)=$P(^PSD(58.8,+PSDS,1,PSDR,0),"^",4)+PSDQTY
|
---|
| 130 | L -^PSD(58.8,+PSDS,1,PSDR,0) W "."
|
---|
| 131 | F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
|
---|
| 132 | FIND1 S PSDA=$P(^PSD(58.81,0),"^",3)+1 I $D(^PSD(58.81,PSDA)) S $P(^PSD(58.81,0),"^",3)=PSDA G FIND1
|
---|
| 133 | K DA,DIC,DLAYGO S (DIC,DLAYGO)=58.81,DIC(0)="L",(X,DINUM)=PSDA D ^DIC K DIC,DLAYGO
|
---|
| 134 | L -^PSD(58.81,0)
|
---|
| 135 | S PSDNUM1=$P($G(PSDNUM),"^",2)
|
---|
| 136 | S ^PSD(58.81,PSDA,0)=PSDA_"^3^"_+PSDS_"^"_PSDT_"^"_PSDR_"^"_PSDQTY_"^"_DUZ_"^^^"_BAL
|
---|
| 137 | S ^PSD(58.81,PSDA,3)=PSDT_"^"_PSDQTY_"^"_"RX RETURNED TO STOCK"
|
---|
| 138 | S ^PSD(58.81,PSDA,"CS")=1
|
---|
| 139 | S ^PSD(58.81,PSDA,6)=PSDRX_"^"_$S($P(PSDNUM,"^")="R":PSDNUM1,1:"")_"^"_DAT_"^"_$S($P(PSDNUM,"^")="P":PSDNUM1,1:"")_"^"_RXNUM
|
---|
| 140 | S DIK="^PSD(58.81,",DA=PSDA D IX^DIK K DA,DIC,DIK
|
---|
| 141 | DIE I '$D(^PSD(58.8,+PSDS,1,PSDR,4,0)) S ^(0)="^58.800119PA^^"
|
---|
| 142 | K DA,DIC,DD,DO S DA(1)=PSDR,DA(2)=+PSDS,(X,DINUM)=PSDA,DIC(0)="L",DIC="^PSD(58.8,"_+PSDS_",1,"_PSDR_",4," D FILE^DICN K DIC,DINUM
|
---|
| 143 | ;monthly activity
|
---|
| 144 | I '$D(^PSD(58.8,+PSDS,1,PSDR,5,0)) S ^(0)="^58.801A^^"
|
---|
| 145 | I '$D(^PSD(58.8,+PSDS,1,PSDR,5,$E(DT,1,5)*100,0)) K DA,DIC S DIC="^PSD(58.8,"_+PSDS_",1,"_PSDR_",5,",DIC(0)="LM",DLAYGO=58.8,(X,DINUM)=$E(DT,1,5)*100,DA(2)=+PSDS,DA(1)=PSDR D ^DIC K DA,DIC,DINUM,DLAYGO
|
---|
| 146 | K DA,DIE,DR S DIE="^PSD(58.8,"_+PSDS_",1,"_PSDR_",5,",DA(2)=+PSDS,DA(1)=PSDR,DA=$E(DT,1,5)*100,DR="9////^S X=$P($G(^(0)),""^"",6)+PSDQTY" D ^DIE K DA,DIE,DR
|
---|
| 147 | RETERR Q
|
---|
| 148 | RTSCHK ;Check to see if already returned to stock.
|
---|
| 149 | D RTSMUL
|
---|
| 150 | S PSD1=0
|
---|
| 151 | S:$D(PSDXXX) PSD1=PSDXXX-.1
|
---|
| 152 | K PSD1MUL,PSDMUL,PSDXXX
|
---|
| 153 | S PSDERR=0
|
---|
| 154 | F S PSD1=$O(^PSD(58.81,"AOP",PSDRX,PSD1)) Q:PSD1'>0 S DATA=$G(^PSD(58.81,PSD1,0)),DATA6=$G(^PSD(58.81,PSD1,6)) D
|
---|
| 155 | .S PSDFLL=$P(PSDNUM,"^",2)
|
---|
| 156 | .I PSDFLL>0,$D(^PSD(58.81,PSD1,6)),$P(^PSD(58.81,PSD1,6),"^",2)=PSDFLL,$D(^PSD(58.81,PSD1,3)) D ERRMSG
|
---|
| 157 | .I $D(^PSD(58.81,PSD1,3)),PSDFLL=0,'$D(^PSD(58.81,PSD1,6)) D ERRMSG
|
---|
| 158 | Q
|
---|
| 159 | ERRMSG S Y=$P(^PSD(58.81,PSD1,3),"^") X ^DD("DD") S PSDRTS(1)=Y,PSDUSER=$P(^PSD(58.81,PSD1,0),"^",7),PSDUSER=$P(^VA(200,PSDUSER,0),"^")
|
---|
| 160 | W !!?8,"According to the Controlled Substances package, this fill/refill",!?8,"was returned to stock on "_PSDRTS(1)_" by "_$G(PSDUSER)_".",!?16,"Nothing updated in the Controlled Substances package."
|
---|
| 161 | S PSDERR=1 Q
|
---|
| 162 | RTSMUL D RTSMUL^PSDOPT1
|
---|
| 163 | Q
|
---|