PSGAL5 ;BIR/CML3-ACTIVITY LOGGER ;22 Jan 99 / 8:00 AM
;;5.0; INPATIENT MEDICATIONS ;**3,22,50**;16 DEC 97
;
;Reference to ^PS(55 is supported by DBIA 2191
;Reference to ^DD is supported by DBIA 903
;
EN ;
N PSJ9,PSJ99 F Q=1:1 Q:'$D(DA(Q+1))
S PSGAL("D0")=DA(Q),PSGAL("D1")=$S(Q=1:DA,1:DA(Q-1))
I PSGAL("C")'=6000,$D(PSGALO),PSGALO S PSGAL("C")=PSGALO
I PSGAL("C")=6000,$D(PSGALR),PSGALR]"" S PSGAL("C")=PSGAL("C")+PSGALR
I $E(PSGAL("C"),1,2)=60 S OLD=X,FLD=$S($D(PSGALFF):PSGALFF,1:0),FN=$S($D(PSGALFN):PSGALFN,1:55.06) D FIELD^DID(FN,FLD,,"SPECIFIER","PSJ9") I OLD]"",$G(PSJ9("SPECIFIER"))["P" S XX=FN,YY=FLD D PNTR
I $E(PSGAL("C"),1,2)=60,OLD]"" D FIELD^DID(FN,FLD,,"SPECIFIER","PSJ9") I $G(PSJ9("SPECIFIER"))["S" S OLDS=$P($P(";"_$P(^DD(FN,FLD,0),"^",3),";"_OLD_":",2),";") I OLDS]"" S OLD=OLDS
;L +^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0) S QQ=$G(^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0)) S:QQ="" QQ="^55.09D" F Q=$P(QQ,"^",3)+1:1 I '$D(^(Q)) S $P(QQ,"^",3,4)=Q_"^"_Q,^(0)=QQ,PSGAL("N")=Q Q
S QQ=$G(^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0)) S:QQ="" QQ="^55.09D" F Q=$P(QQ,"^",3)+1:1 I '$D(^(Q)) S $P(QQ,"^",3,4)=Q_"^"_Q,^(0)=QQ,PSGAL("N")=Q Q
;L -^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0) D NOW^%DTC S PSGDT=+$E(%,1,12)
D NOW^%DTC S PSGDT=+$E(%,1,12)
S Q=%_"^"_$S(PSGAL("C")=6010:"AUTO CANCEL",$D(DUZ)[0:"UNKNOWN",DUZ]"":DUZ,1:"UNKNOWN")_"^"_PSGAL("C")_$S($E(PSGAL("C"),1,2)=60:"^"_$S('$D(^DD(FN,FLD,0)):FLD,$P(^(0),"^")]"":$P(^(0),"^"),1:FLD)_"^"_OLD,1:"")
S ^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,PSGAL("N"),0)=Q I PSGAL("C")=6000,$D(PSGALEF) S PSGALEF=PSGALEF+1
;
DONE ;
S PSGAL("D")=% K OLDS,FLD,FN,OLD,PSGALFF,PSGALFN,SS,XX,YY Q
;
PNTR ; find pointer value
F D FIELD^DID(XX,YY,,"POINTER","PSJ99") S SS=PSJ99("POINTER"),XX=+$P(@("^"_SS_"0)"),"^",2),OLD=$P(@("^"_SS_OLD_",0)"),"^") D FIELD^DID(XX,.01,,"SPECIFIER","PSJ99") Q:$G(PSJ99("SPECIFIER"))'["P" S YY=.01
Q
;
KILL ; if user merely reenters same data (tsk, tsk), kill record just written
K ^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,PSGAL("N"),0) I PSGAL("C")=6000,$D(PSGALEF),PSGALEF S PSGALEF=PSGALEF-1
Q
;
; Create new activity log entry in file #55.
NEWUDAL(PSGALGP,PSGALORD,PSGALC,PSGFLD,PSGOLD) ;
;
;Where PSGALGP = PSGP (Required)
; PSGALORD = PSGORD (Required)
; PSGALC = ACTIVITY CODE FROM #53.3 (Required)
; PSGFLD = FIELD THAT CHANGED (Free text, optional)
; PSGOLD = THE FIELDS OLD DATA VALUE (Free text, optional)
;
;N PSGALGP,PSGALORD,PSGALC,PSGFLD,PSGOLD
;
; Create 0 node activity log for order if not exists, and get next entry number
S QQ=$G(^PS(55,PSGALGP,5,+PSGALORD,9,0)) S:QQ="" QQ="^55.09D" F Q=$P(QQ,"^",3)+1:1 I '$D(^(Q)) S $P(QQ,"^",3,4)=Q_"^"_Q,^(0)=QQ,PSGAL("N")=Q Q
;Set up data to be held in activity log record
D NOW^%DTC S PSGDT=+$E(%,1,12)
I $L($G(PSGOLD))>170 S PSGOLD=$E(PSGOLD,1,167)_"..." ; Use of ... indicates old data field was greater than 170 characters
S Q=%_"^"_$S(PSGALC=6010:"AUTO CANCEL",$D(DUZ)[0:"UNKNOWN",DUZ]"":DUZ,1:"UNKNOWN")_"^"_PSGALC_"^"_$S($D(PSGFLD):PSGFLD,1:"")_"^"_$S($D(PSGOLD):PSGOLD,1:"")
; Create activity log entry
S ^PS(55,PSGALGP,5,+PSGALORD,9,PSGAL("N"),0)=Q
Q
; Create new activity log entry
NEWNVAL(PSGALORD,PSGALC,PSGFLD,PSGOLD) ;
;
;Where PSGALORD = PSGORD (Required)
; PSGALC = ACTIVITY CODE FROM #53.3 (Required)
; PSGFLD = FIELD THAT CHANGED (Free text, optional)
; PSGOLD = THE FIELDS OLD DATA VALUE (Free text, optional)
;
;N PSGALORD,PSGALC,PSGFLD,PSGOLD
;
; Create 0 node activity log for order if not exists, and get next entry number
S QQ=$G(^PS(53.1,+PSGALORD,"A",0)) S:QQ="" QQ="^53.1119D" F Q=$P(QQ,"^",3)+1:1 I '$D(^(Q)) S $P(QQ,"^",3,4)=Q_"^"_Q,^(0)=QQ,PSGAL("N")=Q Q
;Set up data to be held in activity log record
D NOW^%DTC S PSGDT=+$E(%,1,12)
I $L($G(PSGOLD))>170 S PSGOLD=$E(PSGOLD,1,167)_"..." ; Use of ... indicates old data field was greater than 170 characters
S Q=%_"^"_$S(PSGALC=6010:"AUTO CANCEL",$D(DUZ)[0:"UNKNOWN",DUZ]"":DUZ,1:"UNKNOWN")_"^"_PSGALC_"^"_$S($D(PSGFLD):PSGFLD,1:"")_"^"_$S($D(PSGOLD):PSGOLD,1:"")
; Create activity log entry
S ^PS(53.1,+PSGALORD,"A",PSGAL("N"),0)=Q
Q
;
KILLNV ; if user merely reenters same data (tsk, tsk), kill record just written
K ^PS(53.1,PSGAL("D0"),"A",PSGAL("N"),0) I PSGAL("C")=6000,$D(PSGALEF),PSGALEF S PSGALEF=PSGALEF-1
Q
PSGAL5 ;BIR/CML3-ACTIVITY LOGGER ;22 Jan 99 / 8:00 AM
+1 ;;5.0; INPATIENT MEDICATIONS ;**3,22,50**;16 DEC 97
+2 ;
+3 ;Reference to ^PS(55 is supported by DBIA 2191
+4 ;Reference to ^DD is supported by DBIA 903
+5 ;
EN ;
+1 NEW PSJ9,PSJ99
FOR Q=1:1
IF '$DATA(DA(Q+1))
QUIT
+2 SET PSGAL("D0")=DA(Q)
SET PSGAL("D1")=$SELECT(Q=1:DA,1:DA(Q-1))
+3 IF PSGAL("C")'=6000
IF $DATA(PSGALO)
IF PSGALO
SET PSGAL("C")=PSGALO
+4 IF PSGAL("C")=6000
IF $DATA(PSGALR)
IF PSGALR]""
SET PSGAL("C")=PSGAL("C")+PSGALR
+5 IF $EXTRACT(PSGAL("C"),1,2)=60
SET OLD=X
SET FLD=$SELECT($DATA(PSGALFF):PSGALFF,1:0)
SET FN=$SELECT($DATA(PSGALFN):PSGALFN,1:55.06)
DO FIELD^DID(FN,FLD,,"SPECIFIER","PSJ9")
IF OLD]""
IF $GET(PSJ9("SPECIFIER"))["P"
SET XX=FN
SET YY=FLD
DO PNTR
+6 IF $EXTRACT(PSGAL("C"),1,2)=60
IF OLD]""
DO FIELD^DID(FN,FLD,,"SPECIFIER","PSJ9")
IF $GET(PSJ9("SPECIFIER"))["S"
SET OLDS=$PIECE($PIECE(";"_$PIECE(^DD(FN,FLD,0),"^",3),";"_OLD_":",2),";")
IF OLDS]""
SET OLD=OLDS
+7 ;L +^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0) S QQ=$G(^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0)) S:QQ="" QQ="^55.09D" F Q=$P(QQ,"^",3)+1:1 I '$D(^(Q)) S $P(QQ,"^",3,4)=Q_"^"_Q,^(0)=QQ,PSGAL("N")=Q Q
+8 SET QQ=$GET(^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0))
IF QQ=""
SET QQ="^55.09D"
FOR Q=$PIECE(QQ,"^",3)+1:1
IF '$DATA(^(Q))
SET $PIECE(QQ,"^",3,4)=Q_"^"_Q
SET ^(0)=QQ
SET PSGAL("N")=Q
QUIT
+9 ;L -^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,0) D NOW^%DTC S PSGDT=+$E(%,1,12)
+10 DO NOW^%DTC
SET PSGDT=+$EXTRACT(%,1,12)
+11 SET Q=%_"^"_$SELECT(PSGAL("C")=6010:"AUTO CANCEL",$DATA(DUZ)[0:"UNKNOWN",DUZ]"":DUZ,1:"UNKNOWN")_"^"_PSGAL("C")_$SELECT($EXTRACT(PSGAL("C"),1,2)=60:"^"_$SELECT('$DATA(^DD(FN,FLD,0)):FLD,$PIECE(^(0),"^")]"":$PIECE(^(0),"^"),1:FLD)_"^"_OLD,1:"")
+12 SET ^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,PSGAL("N"),0)=Q
IF PSGAL("C")=6000
IF $DATA(PSGALEF)
SET PSGALEF=PSGALEF+1
+13 ;
DONE ;
+1 SET PSGAL("D")=%
KILL OLDS,FLD,FN,OLD,PSGALFF,PSGALFN,SS,XX,YY
QUIT
+2 ;
PNTR ; find pointer value
+1 FOR
DO FIELD^DID(XX,YY,,"POINTER","PSJ99")
SET SS=PSJ99("POINTER")
SET XX=+$PIECE(@("^"_SS_"0)"),"^",2)
SET OLD=$PIECE(@("^"_SS_OLD_",0)"),"^")
DO FIELD^DID(XX,.01,,"SPECIFIER","PSJ99")
IF $GET(PSJ99("SPECIFIER"))'["P"
QUIT
SET YY=.01
+2 QUIT
+3 ;
KILL ; if user merely reenters same data (tsk, tsk), kill record just written
+1 KILL ^PS(55,PSGAL("D0"),5,PSGAL("D1"),9,PSGAL("N"),0)
IF PSGAL("C")=6000
IF $DATA(PSGALEF)
IF PSGALEF
SET PSGALEF=PSGALEF-1
+2 QUIT
+3 ;
+4 ; Create new activity log entry in file #55.
NEWUDAL(PSGALGP,PSGALORD,PSGALC,PSGFLD,PSGOLD) ;
+1 ;
+2 ;Where PSGALGP = PSGP (Required)
+3 ; PSGALORD = PSGORD (Required)
+4 ; PSGALC = ACTIVITY CODE FROM #53.3 (Required)
+5 ; PSGFLD = FIELD THAT CHANGED (Free text, optional)
+6 ; PSGOLD = THE FIELDS OLD DATA VALUE (Free text, optional)
+7 ;
+8 ;N PSGALGP,PSGALORD,PSGALC,PSGFLD,PSGOLD
+9 ;
+10 ; Create 0 node activity log for order if not exists, and get next entry number
+11 SET QQ=$GET(^PS(55,PSGALGP,5,+PSGALORD,9,0))
IF QQ=""
SET QQ="^55.09D"
FOR Q=$PIECE(QQ,"^",3)+1:1
IF '$DATA(^(Q))
SET $PIECE(QQ,"^",3,4)=Q_"^"_Q
SET ^(0)=QQ
SET PSGAL("N")=Q
QUIT
+12 ;Set up data to be held in activity log record
+13 DO NOW^%DTC
SET PSGDT=+$EXTRACT(%,1,12)
+14 ; Use of ... indicates old data field was greater than 170 characters
IF $LENGTH($GET(PSGOLD))>170
SET PSGOLD=$EXTRACT(PSGOLD,1,167)_"..."
+15 SET Q=%_"^"_$SELECT(PSGALC=6010:"AUTO CANCEL",$DATA(DUZ)[0:"UNKNOWN",DUZ]"":DUZ,1:"UNKNOWN")_"^"_PSGALC_"^"_$SELECT($DATA(PSGFLD):PSGFLD,1:"")_"^"_$SELECT($DATA(PSGOLD):PSGOLD,1:"")
+16 ; Create activity log entry
+17 SET ^PS(55,PSGALGP,5,+PSGALORD,9,PSGAL("N"),0)=Q
+18 QUIT
+19 ; Create new activity log entry
NEWNVAL(PSGALORD,PSGALC,PSGFLD,PSGOLD) ;
+1 ;
+2 ;Where PSGALORD = PSGORD (Required)
+3 ; PSGALC = ACTIVITY CODE FROM #53.3 (Required)
+4 ; PSGFLD = FIELD THAT CHANGED (Free text, optional)
+5 ; PSGOLD = THE FIELDS OLD DATA VALUE (Free text, optional)
+6 ;
+7 ;N PSGALORD,PSGALC,PSGFLD,PSGOLD
+8 ;
+9 ; Create 0 node activity log for order if not exists, and get next entry number
+10 SET QQ=$GET(^PS(53.1,+PSGALORD,"A",0))
IF QQ=""
SET QQ="^53.1119D"
FOR Q=$PIECE(QQ,"^",3)+1:1
IF '$DATA(^(Q))
SET $PIECE(QQ,"^",3,4)=Q_"^"_Q
SET ^(0)=QQ
SET PSGAL("N")=Q
QUIT
+11 ;Set up data to be held in activity log record
+12 DO NOW^%DTC
SET PSGDT=+$EXTRACT(%,1,12)
+13 ; Use of ... indicates old data field was greater than 170 characters
IF $LENGTH($GET(PSGOLD))>170
SET PSGOLD=$EXTRACT(PSGOLD,1,167)_"..."
+14 SET Q=%_"^"_$SELECT(PSGALC=6010:"AUTO CANCEL",$DATA(DUZ)[0:"UNKNOWN",DUZ]"":DUZ,1:"UNKNOWN")_"^"_PSGALC_"^"_$SELECT($DATA(PSGFLD):PSGFLD,1:"")_"^"_$SELECT($DATA(PSGOLD):PSGOLD,1:"")
+15 ; Create activity log entry
+16 SET ^PS(53.1,+PSGALORD,"A",PSGAL("N"),0)=Q
+17 QUIT
+18 ;
KILLNV ; if user merely reenters same data (tsk, tsk), kill record just written
+1 KILL ^PS(53.1,PSGAL("D0"),"A",PSGAL("N"),0)
IF PSGAL("C")=6000
IF $DATA(PSGALEF)
IF PSGALEF
SET PSGALEF=PSGALEF-1
+2 QUIT