Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: APSPFNC3

APSPFNC3.m

Go to the documentation of this file.
APSPFNC3 ;IHS/MSC/PLS - auto return to stock/delete support ;21-Aug-2008 14:57;SM
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1006,1007**;Sep 23, 2004
 ; IHS/MSC/PLS - 08/21/08 - Added additional parameter to CALLPOS calls
 ;Code copied from PSORXDL
EN(DA) ; EP
 N PSODEFLG,PSOHLRE,PSOHLDAH,QTY,PSOABCDA,PSOREF,RXP
 N PSDEL,PSOXXDEL,PS,RXN,PSOPLCK,PSOMSG,COM
 N PSORXDFN,REL,PSOGGFL,PSOGG,PSOXYZF,X,Y,Z,DFN,I,PKI1
 N PSODEF
 S (PSDEL,PSOXXDEL)=1,PS="DELETE"
 S RXN=+$G(DA)
 S PSORXDFN=+$P($G(^PSRX(RXN,0)),U,2)
 S PSOPLCK=$$L^PSSLOCK(PSORXDFN,0) I '$G(PSOPLCK) D LOCK^PSOORCPY Q
 D PSOL^PSSLOCK(RXN) I '$G(PSOMSG) D  Q
 .W !,$S($P($G(PSOMSG),U,2)'="":$P($G(PSOMSG),U,2),1:"Another person is editing this order."),!
 .D ULP
 S (REL,PSOGGFL)=0
 F PSOGG=0:0 S PSOGG=$O(^PSRX(DA,1,PSOGG)) Q:'PSOGG  S:$D(^PSRX(DA,1,PSOGG,0)) PSOGGFL=PSOGG
 S REL=$S($G(PSOGGFL)&($P($G(^PSRX(DA,1,+$G(PSOGGFL),0)),U,18))&('$P($G(^(0)),U,16)):1,'$G(PSOGGFL)&($P($G(^PSRX(DA,2)),U,13))&('$P($G(^(2)),U,15)):1,1:0)
PASS ;N PSORXDAC K PSOXYZF S PSORXDAC=$O(^PS(52.5,"B",DA,0)) I PSORXDAC,$P($G(^PS(52.5,PSORXDAC,0)),U,7)="L" N PSOXYZ S PSOXYZF=0 W !!,"Please wait, Rx is Loading for CMOP Transmission.." D
 ;.F PSOXYZ=1:1:5 W "." H 1 I $P($G(^PS(52.5,PSORXDAC,0)),U,7)'="L" S PSOXYZF=1
 ;I $G(PSOXYZF)=0 W !!,"Sorry, still loading for CMOP transmission, try again later.",! D ULK,ULP,KILL K PSOXYZF G PSORXDL
 I $G(REL) S PSOHLRE=REL,PSOHLDAH=$G(DA)
 I $G(REL) S RXP=DA S PSODEFLG=0 D RESK I $G(PSODEFLG) D ULK,ULP,KILL Q
 S:$G(PSOHLRE) DA=$G(PSOHLDAH),REL=$G(PSOHLRE)
 S PSONOOR="S"  ; Service Corrected
 I $G(PKI1) N INCOM S INCOM="Per Pharmacy Request" D DCV^PSOPKIV1,ULK,ULP Q
ENQ S PSOIB=$S($D(^PSRX(DA,"IB")):^PSRX(DA,"IB"),1:0) ;Check if copay
 S RX=^PSRX(DA,0),RXN=DA
 S $P(^PSRX(RXN,"STA"),U)=13,$P(^PSRX(RXN,"D"),U)=$G(Y)
 S DA=RXN K ^PSRX("ACP",$P(^PSRX(DA,0),U,2),+$P(^(2),U,2),0,DA) D ACT
 S DA=RXN I $G(^PSRX(DA,"H"))]"" K ^PSRX("AH",+$P(^PSRX(DA,"H"),U),DA) S ^PSRX(DA,"H")=""
 D EN^PSOHLSN1(DA,"OC","",$P(^PSRX(DA,"D"),U),PSONOOR)
 S DA=$O(^PS(52.5,"B",RXN,0)) I DA S DIK="^PS(52.5," D ^DIK
 S DA=RXN I $D(^PS(52.4,RXN)) S DIK="^PS(52.4," D ^DIK
 K PSOABCDA I $G(DA) S PSOABCDA=$G(DA)
 I $O(^PS(52.41,"ARF",RXN,0)) S DA=$O(^PS(52.41,"ARF",RXN,0)),DIK="^PS(52.41," D ^DIK K DA,DIK
 I $G(PSOABCDA) S DA=$G(PSOABCDA)
 ;I +PSOIB>0,+$P(PSOIB,U,2)>0 D RXDEL^PSOCPA ;If charged, delete copay
 I $G(PSOABCDA) S DA=$G(PSOABCDA) K PSOABCDA
 Q:+$G(PSORX("INTERVENE"))!($G(PSVFLAG))  I $D(DA),'$G(PSOZVER) D ULK,ULP Q
 S ^PSDRUG(+$P(RX,U,6),660.1)=$S($D(^PSDRUG(+$P(RX,U,6),660.1)):^(660.1),1:0)+$P(RX,U,7)
 S DFN=+$P(RX,U,2) F I=0:0 S I=$O(^PS(55,DFN,"P",I)) Q:'I  I +^(I,0)=RXN K ^(0) S ^(0)=$P(^PS(55,DFN,"P",0),U,1,3)_U_($P(^(0),U,4)-1)
 D:'$P($G(^PSRX(RXN,2)),U,15) CALLPOS^APSPFUNC(RXN,"","D","Returned to stock.")
 F I=0:0 S I=$O(^PS(55,DFN,"P","A",I)) Q:'I  I $D(^(I,RXN)) K ^(RXN)
 K STAT,COM,RX,RXN Q:+$G(PSORX("INTERVENE"))!($G(PSVFLAG))  I $G(PSDEL) D ULK,ULP Q
 ;
KILL K PSORXDFN,RXO,RX0,RX2,RESK,PSOPCECT,PSDEL,PS,RFDATE,RFL,RFL1,ST,ST0,%,%Y,DA,DI,DIC,DIE,DIH,DIU,DIV,DR,Z,DIG,X,Y,PSOIB,RX,RXN,PSOREF,PSOHLRE,PSOHLDAH,PSOGG,PSODLCOM
 K DIR,RXP,DIRUT,DUOUT,DTOUT,SIGOK,PSONODF,PSONOOR,PSOXYZF,TYPE,QDRUG,QTY,PSOLOCRL,PSODT,PSOINVTX,PSROF,PSOABCDA,PSOXXDEL
 Q
ACT ;adds activity info for deleted rx
 N RXF,PSOREF,I,DA,FDA,%,%H,%I
 S (RXF,PSOREF)=0 F I=0:0 S I=$O(^PSRX(RXN,1,I)) Q:'I  S (RXF,PSOREF)=I S:I>5 RXF=I+1 K ^PSRX("ACP",$P(^PSRX(RXN,0),U,2),$P(^PSRX(RXN,1,I,0),U),I,RXN)
 S DA=0 F FDA=0:0 S FDA=$O(^PSRX(RXN,"A",FDA)) Q:'FDA  S DA=FDA
 D NOW^%DTC
 S DA=DA+1
 S ^PSRX(RXN,"A",0)="^52.3DA^"_DA_U_DA
 S ^PSRX(RXN,"A",DA,0)=%_U_"D"_U_DUZ_U_RXF_U_"RX DELETED on "_$E(DT,4,5)_"-"_$E(DT,6,7)_"-"_$E(DT,2,3)
EX S DA=RXN
 Q
RESK ;
 N RX0,RX2,J,ST0,ST,PSODLCOM,COM,PSOWHERE,RESK,PSIN,XTYPE,COPAYFLG
 N IFN,I,%,DIR,PSOLOUD,DIE,DIK,QDRUG
 S RESK=1,PSIN=+$P(^PS(59.7,1,49.99),U,2) K PSODEF S PSOPCECT=1
 S PSOLOUD=1 D:$P($G(^PS(55,+$P(^PSRX(RXP,0),U,2),0)),U,6)'=2 EN^PSOHLUP($P(^PSRX(RXP,0),U,2)) K PSOLOUD
 I $S('+$P($G(^PSRX(+RXP,"STA")),U):0,$P(^("STA"),U)=11:0,$P(^("STA"),U)=12:0,$P(^("STA"),U)=14:0,$P(^("STA"),U)=15:0,1:1) D STAT^PSORESK1 S PSODEFLG=1 Q
 K DIR
 S (COM,PSODLCOM)="Auto RTS/Delete"  ;todo-what should the comment text be  ;Y I Y[U!($D(DIRUT)) W !!,"No Action Taken!",! S PSODEFLG=1 Q
 ;The next two lines make use of the MUMPS naked reference syntax.
 S QDRUG=+$P($G(^PSRX(RXP,0)),U,6)
 S QTY=$P($G(^(0)),U,7) I $O(^PSRX(RXP,1,0)) G REF
 S XTYPE="O" I $P($G(^PSRX(RXP,2)),U,15) Q  ;Already returned to stock
 I $P($G(^PSRX(RXP,2)),U,2)<$G(PSIN) Q  ;Fill Date < OP v6 Install Date
 K PSOLOCRL,PSOWHERE S PSOLOCRL=$P($G(^PSRX(RXP,2)),U,13)  ; Released D/T
 Q:'$G(PSOLOCRL)
 S PSOWHERE=$S($D(^PSRX("AR",$G(PSOLOCRL),RXP,0)):1,1:0)
 I $G(^PSDRUG(QDRUG,660.1)),$G(PSOWHERE) D INVT W:$G(PSODEFLG) !!?5,"No Action Taken!",! Q:$G(PSODEFLG)  I $G(PSOINVTX) D INVINC
 I $G(^PSDRUG(QDRUG,660.1)),'$G(PSOWHERE) D INVINC
 I $G(PSOWHERE) K ^PSRX("AR",$G(PSOLOCRL),RXP,0)
 D NOW^%DTC K DIE S DA=RXP,DIE="^PSRX(",DR="31///@;32.1///"_% D ^DIE K DIE
 D ACT^PSORESK1
 S DA=$O(^PS(52.5,"B",RXP,0)) I DA K DIK S DIK="^PS(52.5," D ^DIK K DIK
 D EN^PSOHLSN1(RXP,"ZD")
 D CALLPOS^APSPFUNC(RXP,"","D","Returned to stock.")
 Q
REF ;
 N TYPE
 F PSROF=0:0 S PSROF=$O(^PSRX(RXP,1,PSROF)) Q:'PSROF  S:$P($G(^PSRX(RXP,1,PSROF,0)),U) TYPE=PSROF
 Q:'$G(TYPE)
 S XTYPE=1
 Q:$P($G(^PSRX(RXP,1,TYPE,0)),U,16)
 Q:'$P($G(^PSRX(RXP,1,TYPE,0)),U,18)
 I '$P($G(^PSRX(RXP,1,TYPE,0)),U,18),$P($G(^(0)),U)'<PSIN Q
 S PSOLOCRL=$P($G(^PSRX(RXP,1,TYPE,0)),U,18)
 Q:'$G(PSOLOCRL)
 S PSOWHERE=$S($D(^PSRX("AR",$G(PSOLOCRL),RXP,TYPE)):1,1:0)
 S QTY=$P($G(^PSRX(RXP,1,TYPE,0)),U,4)
 I +$G(^PSRX(RXP,"IB")) S COPAYFLG=1 D CP^PSORESK1 I '$G(COPAYFLG) S PSODEFLG=1 Q
 I $G(^PSDRUG(QDRUG,660.1)),$G(PSOWHERE) D INVT W:$G(PSODEFLG) !!?5,"No Action Taken!",! Q:$G(PSODEFLG)  I $G(PSOINVTX) D INVINC
 I $G(^PSDRUG(QDRUG,660.1)),'$G(PSOWHERE) D INVINC
 I $G(PSOWHERE) K ^PSRX("AR",$G(PSOLOCRL),RXP,TYPE)
 D NOW^%DTC K DIE S DA(1)=RXP,DA=TYPE,DIE="^PSRX("_DA(1)_",1,",DR="17////@;.01///@" W ! D ^DIE K DIE
 D ACT^PSORESK1
 S DA=$O(^PS(52.5,"B",RXP,0)) I DA K DIK S DIK="^PS(52.5," D ^DIK K DIK
 D EN^PSOHLSN1(RXP,"ZD")
 D CALLPOS^APSPFUNC(RXP,$S(TYPE:TYPE,1:""),"D","Returned to stock.")
 Q
INVT ;
 S PSOINVTX=1
 Q
INVINC ;
 S ^PSDRUG(QDRUG,660.1)=$S($P($G(^PSDRUG(QDRUG,660.1)),U):$P($G(^PSDRUG(QDRUG,660.1)),U),1:0)+$G(QTY)
 Q
ULK ;
 I $G(RXN) D PSOUL^PSSLOCK(RXN)
 Q
ULP ;
 D UL^PSSLOCK(+$G(PSORXDFN))
 Q