PSOSUCH1 ;BHAM ISC/JMB-Change suspense and fill/refill dates ; 4/49/93
;;7.0;OUTPATIENT PHARMACY;**148**;DEC 1997
LISTSUS S X="?",DIC("S")="I $D(^PSRX(+$P(^PS(52.5,+Y,0),""^""),0)),$P($G(^(""STA"")),""^"")<11,$P($G(^PS(52.5,+Y,""P"")),""^"")=0",DIC="^PS(52.5,",DIC(0)="ZQ" D ^DIC K DIC W ! Q:Y<0!($D(DTOUT)) Q
LISTPAT S X="?",DIC(0)="EMQ",DIC="^DPT(",DIC("S")="I $D(^PS(52.5,""AC"",+Y))" D ^DIC K DIC Q
PSOINST S PSOINST=$P($G(^DIC(4,+$P($G(^XMB(1,1,"XUS")),"^",17),99)),"^") I Y["-",'$D(^PSRX($P(Y,"-",2),0)) W !,?7,$C(7),$C(7),$C(7)," NON-EXISTENT PRESCRIPTION" G SPEC^PSOSUCHG:ACT="S" G ALL^PSOSUCHG:ACT="A"
I Y["-",$P(Y,"-")'=PSOINST W !,?7,$C(7),$C(7),$C(7)," NOT FROM THIS INSTITUTION" G SPEC^PSOSUCHG:ACT="S" G ALL^PSOSUCHG:ACT="A"
Q
AREC S:'DEAD COM="Change "_$S($G(PSOSUSPA):"Partial",'$G(SUB):"Fill",1:"Refill")_" Date "_$E(OLD,4,5)_"/"_$E(OLD,6,7)_"/"_$E(OLD,2,3)_" to "_$E(INDT,4,5)_"/"_$E(INDT,6,7)_"/"_$E(INDT,2,3)
S CNT=0 F SUB=0:0 S SUB=$O(^PSRX(RXREC,"A",SUB)) Q:'SUB S CNT=SUB
S RFCNT=0 F RF=0:0 S RF=$O(^PSRX(RXREC,1,RF)) Q:'RF S RFCNT=RF S:RF>5 RFCNT=RF+1
D NOW^%DTC S CNT=CNT+1 S ^PSRX(RXREC,"A",0)="^52.3DA^"_CNT_"^"_CNT,^PSRX(RXREC,"A",CNT,0)=%_"^"_$S(DEAD:"C",1:"S")_"^"_DUZ_"^"_$S($G(PSOSUSPA):6,1:RFCNT)_"^"_COM K PSOSUSPA Q
CHKDEAD D DEM^VADPT I VADM(1)="" W !?10,"PATIENT NAME UNKNOWN" S DEAD=0 Q
I VADM(6)="" S DEAD=0 Q
S SUSDOD=$P(VADM(6),"^",2)
F RXREC=0:0 S RXREC=$O(^PS(52.5,"AC",DFN,RXREC)) Q:'RXREC F SRXREC=0:0 S SRXREC=$O(^PS(52.5,"AC",DFN,RXREC,SRXREC)) Q:'SRXREC S RECORD=$P($G(^PS(52.5,SRXREC,0)),"^") D:RECORD DEAD
Q
DEAD S HOLD=$G(DA),REA="C",COM="Died ("_$G(SUSDOD)_")",DA=RECORD,DEAD=1 D CAN^PSOCAN
W:'WARN !!,?10,$P($G(^DPT(DFN,0)),"^")_" DIED "_SUSDOD_" all prescriptions were discontinued" W:'WARN !,?15," and deleted from the suspense file." S WARN=1,DA=HOLD K HOLD,REA
Q
NEXT S PSOX("IRXN")=RXREC D NEXT^PSOUTIL(.PSOX) S NEXT=$P(PSOX("RX3"),"^",2),DA=RXREC,DIE=52,DR="102///"_NEXT D ^DIE K DIE Q:$D(DTOUT)!($D(DUOUT))
K NEXT,PSOX Q
;
CHANGE(RXREC,SUB) ; File update for Suspense Date change
I $P($G(^PS(52.5,SFN,0)),"^",5) S PSOSUSPA=1,HDSFN=SFN S SRXPAR=+$P(^(0),"^",5),OLD=+$P($G(^PSRX(RXREC,"P",SRXPAR,0)),"^"),DA(1)=RXREC,DA=SRXPAR,DIE="^PSRX("_DA(1)_",""P"",",DR=".01////"_INDT D ^DIE G FIN
I '$D(SUB) S SUB=0 F II=0:0 S II=$O(^PSRX(RXREC,1,II)) Q:'II S SUB=+II
S HDSFN=SFN I 'SUB S (X,OLD)=$P(^PSRX(RXREC,2),"^",2),DA=RXREC,DR="22///"_INDT_";101///"_INDT,DIE=52 D
.D ^DIE K DIE K:$G(^PS(52.5,HDSFN,"P"))=1 ^PS(52.5,"AC",DFN,+$P($G(^PS(52.5,HDSFN,0)),"^",2),HDSFN) Q:$D(DTOUT)!($D(DUOUT)) D NEXT K DA Q
I SUB S (OLD,X)=+$P($G(^PSRX(RXREC,1,SUB,0)),"^"),DA(1)=RXREC,DA=SUB,DIE="^PSRX("_DA(1)_",1,",DR=".01///"_INDT D ^DIE K DIE S $P(^PSRX(RXREC,3),"^")=INDT D
.K:$G(^PS(52.5,HDSFN,"P"))=1 ^PS(52.5,"AC",DFN,+$P($G(^PS(52.5,HDSFN,0)),"^",2),HDSFN) D NEXT S DA=RXREC K DA Q
FIN S DA=HDSFN,DIK="^PS(52.5," D IX1^DIK
S SFN=HDSFN D AREC N X S X="PSXCH" X ^%ZOSF("TEST") K X Q:'$T D:$G(XOK)=1 X^PSXCH Q
Q
;
DAREC ;
S SCOM="Rx "_$S($P(SNODE,"^",5):"(Partial) ",1:"")_"deleted from suspense"
S SSX=0 F SSXX=0:0 S SSXX=$O(^PSRX(RXREC,"A",SSXX)) Q:'SSXX S SSX=SSXX
S SXCNT=0 F SCXX=0:0 S SCXX=$O(^PSRX(RXREC,1,SCXX)) Q:'SCXX S SXCNT=SCXX S:SCXX>5 SXCNT=SCXX+1
D NOW^%DTC S SSX=SSX+1 S ^PSRX(RXREC,"A",0)="^52.3DA^"_SSX_"^"_SSX,^PSRX(RXREC,"A",SSX,0)=%_"^"_"S"_"^"_DUZ_"^"_$S($P(SNODE,"^",5):6,1:SXCNT)_"^"_SCOM
K SCOM,SSX,SSXX,SXCNT,SCXX Q
PSOSUCH1 ;BHAM ISC/JMB-Change suspense and fill/refill dates ; 4/49/93
+1 ;;7.0;OUTPATIENT PHARMACY;**148**;DEC 1997
LISTSUS SET X="?"
SET DIC("S")="I $D(^PSRX(+$P(^PS(52.5,+Y,0),""^""),0)),$P($G(^(""STA"")),""^"")<11,$P($G(^PS(52.5,+Y,""P"")),""^"")=0"
SET DIC="^PS(52.5,"
SET DIC(0)="ZQ"
DO ^DIC
KILL DIC
WRITE !
IF Y<0!($DATA(DTOUT))
QUIT
QUIT
LISTPAT SET X="?"
SET DIC(0)="EMQ"
SET DIC="^DPT("
SET DIC("S")="I $D(^PS(52.5,""AC"",+Y))"
DO ^DIC
KILL DIC
QUIT
PSOINST SET PSOINST=$PIECE($GET(^DIC(4,+$PIECE($GET(^XMB(1,1,"XUS")),"^",17),99)),"^")
IF Y["-"
IF '$DATA(^PSRX($PIECE(Y,"-",2),0))
WRITE !,?7,$CHAR(7),$CHAR(7),$CHAR(7)," NON-EXISTENT PRESCRIPTION"
IF ACT="S"
GOTO SPEC^PSOSUCHG
IF ACT="A"
GOTO ALL^PSOSUCHG
+1 IF Y["-"
IF $PIECE(Y,"-")'=PSOINST
WRITE !,?7,$CHAR(7),$CHAR(7),$CHAR(7)," NOT FROM THIS INSTITUTION"
IF ACT="S"
GOTO SPEC^PSOSUCHG
IF ACT="A"
GOTO ALL^PSOSUCHG
+2 QUIT
AREC IF 'DEAD
SET COM="Change "_$SELECT($GET(PSOSUSPA):"Partial",'$GET(SUB):"Fill",1:"Refill")_" Date "_$EXTRACT(OLD,4,5)_"/"_$EXTRACT(OLD,6,7)_"/"_$EXTRACT(OLD,2,3)_" to "_$EXTRACT(INDT,4,5)_"/"_$EXTRACT(INDT,6,7)_"/"_$EXTRACT(INDT,2,3)
+1 SET CNT=0
FOR SUB=0:0
SET SUB=$ORDER(^PSRX(RXREC,"A",SUB))
IF 'SUB
QUIT
SET CNT=SUB
+2 SET RFCNT=0
FOR RF=0:0
SET RF=$ORDER(^PSRX(RXREC,1,RF))
IF 'RF
QUIT
SET RFCNT=RF
IF RF>5
SET RFCNT=RF+1
+3 DO NOW^%DTC
SET CNT=CNT+1
SET ^PSRX(RXREC,"A",0)="^52.3DA^"_CNT_"^"_CNT
SET ^PSRX(RXREC,"A",CNT,0)=%_"^"_$SELECT(DEAD:"C",1:"S")_"^"_DUZ_"^"_$SELECT($GET(PSOSUSPA):6,1:RFCNT)_"^"_COM
KILL PSOSUSPA
QUIT
CHKDEAD DO DEM^VADPT
IF VADM(1)=""
WRITE !?10,"PATIENT NAME UNKNOWN"
SET DEAD=0
QUIT
+1 IF VADM(6)=""
SET DEAD=0
QUIT
+2 SET SUSDOD=$PIECE(VADM(6),"^",2)
+3 FOR RXREC=0:0
SET RXREC=$ORDER(^PS(52.5,"AC",DFN,RXREC))
IF 'RXREC
QUIT
FOR SRXREC=0:0
SET SRXREC=$ORDER(^PS(52.5,"AC",DFN,RXREC,SRXREC))
IF 'SRXREC
QUIT
SET RECORD=$PIECE($GET(^PS(52.5,SRXREC,0)),"^")
IF RECORD
DO DEAD
+4 QUIT
DEAD SET HOLD=$GET(DA)
SET REA="C"
SET COM="Died ("_$GET(SUSDOD)_")"
SET DA=RECORD
SET DEAD=1
DO CAN^PSOCAN
+1 IF 'WARN
WRITE !!,?10,$PIECE($GET(^DPT(DFN,0)),"^")_" DIED "_SUSDOD_" all prescriptions were discontinued"
IF 'WARN
WRITE !,?15," and deleted from the suspense file."
SET WARN=1
SET DA=HOLD
KILL HOLD,REA
+2 QUIT
NEXT SET PSOX("IRXN")=RXREC
DO NEXT^PSOUTIL(.PSOX)
SET NEXT=$PIECE(PSOX("RX3"),"^",2)
SET DA=RXREC
SET DIE=52
SET DR="102///"_NEXT
DO ^DIE
KILL DIE
IF $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+1 KILL NEXT,PSOX
QUIT
+2 ;
CHANGE(RXREC,SUB) ; File update for Suspense Date change
+1 IF $PIECE($GET(^PS(52.5,SFN,0)),"^",5)
SET PSOSUSPA=1
SET HDSFN=SFN
SET SRXPAR=+$PIECE(^(0),"^",5)
SET OLD=+$PIECE($GET(^PSRX(RXREC,"P",SRXPAR,0)),"^")
SET DA(1)=RXREC
SET DA=SRXPAR
SET DIE="^PSRX("_DA(1)_",""P"","
SET DR=".01////"_INDT
DO ^DIE
GOTO FIN
+2 IF '$DATA(SUB)
SET SUB=0
FOR II=0:0
SET II=$ORDER(^PSRX(RXREC,1,II))
IF 'II
QUIT
SET SUB=+II
+3 SET HDSFN=SFN
IF 'SUB
SET (X,OLD)=$PIECE(^PSRX(RXREC,2),"^",2)
SET DA=RXREC
SET DR="22///"_INDT_";101///"_INDT
SET DIE=52
Begin DoDot:1
+4 DO ^DIE
KILL DIE
IF $GET(^PS(52.5,HDSFN,"P"))=1
KILL ^PS(52.5,"AC",DFN,+$PIECE($GET(^PS(52.5,HDSFN,0)),"^",2),HDSFN)
IF $DATA(DTOUT)!($DATA(DUOUT))
QUIT
DO NEXT
KILL DA
QUIT
End DoDot:1
+5 IF SUB
SET (OLD,X)=+$PIECE($GET(^PSRX(RXREC,1,SUB,0)),"^")
SET DA(1)=RXREC
SET DA=SUB
SET DIE="^PSRX("_DA(1)_",1,"
SET DR=".01///"_INDT
DO ^DIE
KILL DIE
SET $PIECE(^PSRX(RXREC,3),"^")=INDT
Begin DoDot:1
+6 IF $GET(^PS(52.5,HDSFN,"P"))=1
KILL ^PS(52.5,"AC",DFN,+$PIECE($GET(^PS(52.5,HDSFN,0)),"^",2),HDSFN)
DO NEXT
SET DA=RXREC
KILL DA
QUIT
End DoDot:1
FIN SET DA=HDSFN
SET DIK="^PS(52.5,"
DO IX1^DIK
+1 SET SFN=HDSFN
DO AREC
NEW X
SET X="PSXCH"
XECUTE ^%ZOSF("TEST")
KILL X
IF '$TEST
QUIT
IF $GET(XOK)=1
DO X^PSXCH
QUIT
+2 QUIT
+3 ;
DAREC ;
+1 SET SCOM="Rx "_$SELECT($PIECE(SNODE,"^",5):"(Partial) ",1:"")_"deleted from suspense"
+2 SET SSX=0
FOR SSXX=0:0
SET SSXX=$ORDER(^PSRX(RXREC,"A",SSXX))
IF 'SSXX
QUIT
SET SSX=SSXX
+3 SET SXCNT=0
FOR SCXX=0:0
SET SCXX=$ORDER(^PSRX(RXREC,1,SCXX))
IF 'SCXX
QUIT
SET SXCNT=SCXX
IF SCXX>5
SET SXCNT=SCXX+1
+4 DO NOW^%DTC
SET SSX=SSX+1
SET ^PSRX(RXREC,"A",0)="^52.3DA^"_SSX_"^"_SSX
SET ^PSRX(RXREC,"A",SSX,0)=%_"^"_"S"_"^"_DUZ_"^"_$SELECT($PIECE(SNODE,"^",5):6,1:SXCNT)_"^"_SCOM
+5 KILL SCOM,SSX,SSXX,SXCNT,SCXX
QUIT